Beispiel #1
0
 /**
  * Run CasperJS tests.
  * @return bool
  */
 public function execute()
 {
     $this->phpci->logExecOutput(false);
     $casperJs = $this->phpci->findBinary('casperjs');
     if (!$casperJs) {
         $this->phpci->logFailure(Lang::get('could_not_find', 'casperjs'));
         return false;
     }
     $curdir = getcwd();
     chdir($this->phpci->buildPath);
     $cmd = $casperJs . " test {$this->tests_path} --xunit={$this->x_unit_file_path} {$this->arguments}";
     $success = $this->phpci->executeCommand($cmd);
     chdir($curdir);
     $xUnitString = file_get_contents($this->x_unit_file_path);
     try {
         $xUnitParser = new XUnitParser($xUnitString);
         $output = $xUnitParser->parse();
         $failures = $xUnitParser->getTotalFailures();
     } catch (\Exception $ex) {
         $this->phpci->logFailure($xUnitParser);
         throw $ex;
     }
     $this->build->storeMeta('casperJs-errors', $failures);
     $this->build->storeMeta('casperJs-data', $output);
     $this->phpci->logExecOutput(true);
     return $success;
 }
 /**
  * Runs PHP Mess Detector in a specified directory.
  */
 public function execute()
 {
     $jshintBinaryPath = $this->phpci->findBinary('jshint');
     $this->executeJsHint($jshintBinaryPath);
     list($errorCount, $data) = $this->processReport(trim($this->phpci->getLastOutput()));
     $this->build->storeMeta('jshint-warnings', $errorCount);
     $this->build->storeMeta('jshint-data', $data);
     return $this->wasLastExecSuccessful($errorCount);
 }
Beispiel #3
0
 /**
  * Executes parallel lint
  */
 public function execute()
 {
     list($ignore) = $this->getFlags();
     $phplint = $this->phpci->findBinary('parallel-lint');
     $cmd = $phplint . ' %s "%s"';
     $success = $this->phpci->executeCommand($cmd, $ignore, $this->directory);
     $output = $this->phpci->getLastOutput();
     $matches = array();
     if (preg_match_all('/Parse error\\:/', $output, $matches)) {
         $this->build->storeMeta('phplint-errors', count($matches[0]));
     }
     return $success;
 }
Beispiel #4
0
 /**
  * Executes phptal lint
  */
 public function execute()
 {
     $this->phpci->quiet = true;
     $this->phpci->logExecOutput(false);
     foreach ($this->directories as $dir) {
         $this->lintDirectory($dir);
     }
     $this->phpci->quiet = false;
     $this->phpci->logExecOutput(true);
     $errors = 0;
     $warnings = 0;
     foreach ($this->failedPaths as $path) {
         if ($path['type'] == 'error') {
             $errors++;
         } else {
             $warnings++;
         }
     }
     $this->build->storeMeta('phptallint-warnings', $warnings);
     $this->build->storeMeta('phptallint-errors', $errors);
     $this->build->storeMeta('phptallint-data', $this->failedPaths);
     $success = true;
     if ($this->allowed_warnings != -1 && $warnings > $this->allowed_warnings) {
         $success = false;
     }
     if ($this->allowed_errors != -1 && $errors > $this->allowed_errors) {
         $success = false;
     }
     return $success;
 }
Beispiel #5
0
 /**
  * Run tests from a Codeception config file.
  * @param $configPath
  * @return bool|mixed
  * @throws \Exception
  */
 protected function runConfigFile($configPath)
 {
     $this->phpci->logExecOutput(false);
     $codecept = $this->phpci->findBinary('codecept');
     if (!$codecept) {
         $this->phpci->logFailure(Lang::get('could_not_find', 'codecept'));
         return false;
     }
     $cmd = 'cd "%s" && ' . $codecept . ' run -c "%s" --xml ' . $this->args;
     if (IS_WIN) {
         $cmd = 'cd /d "%s" && ' . $codecept . ' run -c "%s" --xml ' . $this->args;
     }
     $configPath = $this->phpci->buildPath . $configPath;
     $success = $this->phpci->executeCommand($cmd, $this->phpci->buildPath, $configPath);
     $this->phpci->log('Codeception XML path: ' . $this->phpci->buildPath . $this->path . 'report.xml', Loglevel::DEBUG);
     $xml = file_get_contents($this->phpci->buildPath . $this->path . 'report.xml', false);
     $parser = new Parser($this->phpci, $xml);
     $output = $parser->parse();
     $meta = array('tests' => $parser->getTotalTests(), 'timetaken' => $parser->getTotalTimeTaken(), 'failures' => $parser->getTotalFailures());
     $this->build->storeMeta('codeception-meta', $meta);
     $this->build->storeMeta('codeception-data', $output);
     $this->build->storeMeta('codeception-errors', $parser->getTotalFailures());
     $this->phpci->logExecOutput(true);
     return $success;
 }
Beispiel #6
0
 /**
  * Runs PHP Spec tests.
  */
 public function execute()
 {
     $curdir = getcwd();
     chdir($this->phpci->buildPath);
     $phpspec = $this->phpci->findBinary(array('phpspec', 'phpspec.php'));
     if (!$phpspec) {
         $this->phpci->logFailure(PHPCI\Helper\Lang::get('could_not_find', 'phpspec'));
         return false;
     }
     $success = $this->phpci->executeCommand($phpspec . ' --format=junit --no-code-generation run');
     $output = $this->phpci->getLastOutput();
     chdir($curdir);
     /*
      * process xml output
      *
      * <testsuites time=FLOAT tests=INT failures=INT errors=INT>
      *   <testsuite name=STRING time=FLOAT tests=INT failures=INT errors=INT skipped=INT>
      *     <testcase name=STRING time=FLOAT classname=STRING status=STRING/>
      *   </testsuite>
      * </testsuites
      */
     $xml = new \SimpleXMLElement($output);
     $attr = $xml->attributes();
     $data = array('time' => (double) $attr['time'], 'tests' => (int) $attr['tests'], 'failures' => (int) $attr['failures'], 'errors' => (int) $attr['errors'], 'suites' => array());
     /**
      * @var \SimpleXMLElement $group
      */
     foreach ($xml->xpath('testsuite') as $group) {
         $attr = $group->attributes();
         $suite = array('name' => (string) $attr['name'], 'time' => (double) $attr['time'], 'tests' => (int) $attr['tests'], 'failures' => (int) $attr['failures'], 'errors' => (int) $attr['errors'], 'skipped' => (int) $attr['skipped'], 'cases' => array());
         /**
          * @var \SimpleXMLElement $child
          */
         foreach ($group->xpath('testcase') as $child) {
             $attr = $child->attributes();
             $case = array('name' => (string) $attr['name'], 'classname' => (string) $attr['classname'], 'time' => (double) $attr['time'], 'status' => (string) $attr['status']);
             if ($case['status'] == 'failed') {
                 $error = array();
                 /*
                  * ok, sad, we had an error
                  *
                  * there should be one - foreach makes this easier
                  */
                 foreach ($child->xpath('failure') as $failure) {
                     $attr = $failure->attributes();
                     $error['type'] = (string) $attr['type'];
                     $error['message'] = (string) $attr['message'];
                 }
                 foreach ($child->xpath('system-err') as $system_err) {
                     $error['raw'] = (string) $system_err;
                 }
                 $case['error'] = $error;
             }
             $suite['cases'][] = $case;
         }
         $data['suites'][] = $suite;
     }
     $this->build->storeMeta('phpspec', $data);
     return $success;
 }
Beispiel #7
0
 /**
  * Runs PHP Mess Detector in a specified directory.
  */
 public function execute()
 {
     if (!$this->tryAndProcessRules()) {
         return false;
     }
     $phpmdBinaryPath = $this->phpci->findBinary('phpmd');
     $this->executePhpMd($phpmdBinaryPath);
     $errorCount = $this->processReport(trim($this->phpci->getLastOutput()));
     $this->build->storeMeta('phpmd-warnings', $errorCount);
     return $this->wasLastExecSuccessful($errorCount);
 }
Beispiel #8
0
 /**
  * Runs PHP Mess Detector in a specified directory.
  */
 public function execute()
 {
     if (!$this->tryAndProcessRules()) {
         return false;
     }
     $phpmdBinaryPath = $this->phpci->findBinary('phpmd');
     if (!$phpmdBinaryPath) {
         $this->phpci->logFailure(PHPCI\Helper\Lang::get('could_not_find', 'phpmd'));
         return false;
     }
     $this->executePhpMd($phpmdBinaryPath);
     list($errorCount, $data) = $this->processReport(trim($this->phpci->getLastOutput()));
     $this->build->storeMeta('phpmd-warnings', $errorCount);
     $this->build->storeMeta('phpmd-data', $data);
     return $this->wasLastExecSuccessful($errorCount);
 }
 /**
  * Runs PHP Mess Detector in a specified directory.
  */
 public function execute()
 {
     // Check that the binary exists:
     $checker = $this->phpci->findBinary('phpdoccheck');
     if (!$checker) {
         $this->phpci->logFailure(PHPCI\Helper\Lang::get('could_not_find', 'phpdoccheck'));
         return false;
     }
     // Build ignore string:
     $ignore = '';
     if (count($this->ignore)) {
         $ignore = ' --exclude="' . implode(',', $this->ignore) . '"';
     }
     // Are we skipping any checks?
     $add = '';
     if ($this->skipClasses) {
         $add .= ' --skip-classes';
     }
     if ($this->skipMethods) {
         $add .= ' --skip-methods';
     }
     // Build command string:
     $path = $this->phpci->buildPath . $this->path;
     $cmd = $checker . ' --json --directory="%s"%s%s';
     // Disable exec output logging, as we don't want the XML report in the log:
     $this->phpci->logExecOutput(false);
     // Run checker:
     $this->phpci->executeCommand($cmd, $path, $ignore, $add);
     // Re-enable exec output logging:
     $this->phpci->logExecOutput(true);
     $output = json_decode($this->phpci->getLastOutput(), true);
     $errors = count($output);
     $success = true;
     $this->build->storeMeta('phpdoccheck-warnings', $errors);
     $this->build->storeMeta('phpdoccheck-data', $output);
     $this->reportErrors($output);
     if ($this->allowed_warnings != -1 && $errors > $this->allowed_warnings) {
         $success = false;
     }
     return $success;
 }
Beispiel #10
0
 /**
  * {@inheritDoc}
  */
 public function execute()
 {
     $success = true;
     $this->phpci->logExecOutput(false);
     // Run any config files first. This can be either a single value or an array
     if ($this->configFile !== null) {
         $success &= $this->runConfigFile($this->configFile);
     }
     $tapString = file_get_contents($this->phpci->buildPath . $this->logPath . DIRECTORY_SEPARATOR . 'report.tap.log');
     try {
         $tapParser = new TapParser($tapString);
         $output = $tapParser->parse();
     } catch (\Exception $ex) {
         $this->phpci->logFailure($tapString);
         throw $ex;
     }
     $failures = $tapParser->getTotalFailures();
     $this->build->storeMeta('codeception-errors', $failures);
     $this->build->storeMeta('codeception-data', $output);
     $this->phpci->logExecOutput(true);
     return $success;
 }