예제 #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;
 }
예제 #2
0
 /**
  * Runs PHP Code Sniffer in a specified directory, to a specified standard.
  */
 public function execute()
 {
     list($ignore, $standard, $suffixes) = $this->getFlags();
     $phpcs = $this->phpci->findBinary('phpcs');
     if (!$phpcs) {
         $this->phpci->logFailure('Could not find phpcs.');
         return false;
     }
     $this->phpci->logExecOutput(false);
     $cmd = $phpcs . ' --report=json %s %s %s %s %s "%s"';
     $this->phpci->executeCommand($cmd, $standard, $suffixes, $ignore, $this->tab_width, $this->encoding, $this->phpci->buildPath . $this->path);
     $output = $this->phpci->getLastOutput();
     list($errors, $warnings, $data) = $this->processReport($output);
     $this->phpci->logExecOutput(true);
     $success = true;
     $this->build->storeMeta('phpcs-warnings', $warnings);
     $this->build->storeMeta('phpcs-errors', $errors);
     $this->build->storeMeta('phpcs-data', $data);
     if ($this->allowed_warnings != -1 && $warnings > $this->allowed_warnings) {
         $success = false;
     }
     if ($this->allowed_errors != -1 && $errors > $this->allowed_errors) {
         $success = false;
     }
     return $success;
 }
예제 #3
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;
 }
예제 #4
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;
 }
예제 #5
0
 /**
  * Execute JSHint.
  * @param $binaryPath
  */
 protected function executeJsHint($binaryPath)
 {
     $cmd = $binaryPath . ' %s --reporter checkstyle';
     $path = $this->getTargetPath();
     // Disable exec output logging, as we don't want the XML report in the log:
     $this->phpci->logExecOutput(false);
     // Run JSHint:
     $this->phpci->executeCommand($cmd, $path);
     // Re-enable exec output logging:
     $this->phpci->logExecOutput(true);
 }
예제 #6
0
 /**
  * Runs the plugin
  */
 public function execute()
 {
     $success = true;
     $this->phpci->logExecOutput(false);
     $errorCount = $this->getErrorList();
     $this->phpci->log("Found {$errorCount} instances of " . implode(', ', $this->searches));
     $this->build->storeMeta('technical_debt-warnings', $errorCount);
     if ($this->allowed_errors != -1 && $errorCount > $this->allowed_errors) {
         $success = false;
     }
     return $success;
 }
예제 #7
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;
 }
예제 #8
0
 /**
  * {@inheritdoc}
  */
 public function execute()
 {
     $curdir = getcwd();
     chdir($this->phpci->buildPath);
     if (!is_file($this->configFile)) {
         $this->phpci->logFailure(sprintf('The Atoum config file "%s" is missing.', $this->configFile));
         chdir($curdir);
         return false;
     }
     $this->phpci->logExecOutput(false);
     $status = $this->phpci->executeCommand('php %s -c %s -ft -utr', $this->executable, $this->configFile);
     $this->phpci->logExecOutput(true);
     try {
         $parser = new TapParser(mb_convert_encoding('TAP version 13' . PHP_EOL . $this->phpci->getLastOutput(), 'UTF-8', 'ISO-8859-1'));
         $data = $parser->parse();
         $this->reportErrors($data);
     } catch (\Exception $exception) {
         $status = false;
         $this->phpci->logFailure('Impossible to parse the Atoum output.', $exception);
     }
     chdir($curdir);
     return $status;
 }
예제 #9
0
 /**
  * Execute PHP Mess Detector.
  * @param $binaryPath
  */
 protected function executePhpMd($binaryPath)
 {
     $cmd = $binaryPath . ' "%s" xml %s %s %s';
     $path = $this->getTargetPath();
     $ignore = '';
     if (count($this->ignore)) {
         $ignore = ' --exclude ' . implode(',', $this->ignore);
     }
     $suffixes = '';
     if (count($this->suffixes)) {
         $suffixes = ' --suffixes ' . implode(',', $this->suffixes);
     }
     // Disable exec output logging, as we don't want the XML report in the log:
     $this->phpci->logExecOutput(false);
     // Run PHPMD:
     $this->phpci->executeCommand($cmd, $path, implode(',', $this->rules), $ignore, $suffixes);
     // Re-enable exec output logging:
     $this->phpci->logExecOutput(true);
 }
예제 #10
0
 /**
  * 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;
 }
예제 #11
0
 /**
  * Uses git diff to figure out what the diff line position is, based on the error line number.
  * @param Builder $builder
  * @param $file
  * @param $line
  * @return int|null
  */
 protected function getDiffLineNumber(Builder $builder, $file, $line)
 {
     $builder->logExecOutput(false);
     $prNumber = $this->getExtra('pull_request_number');
     $path = $builder->buildPath;
     if (!empty($prNumber)) {
         $builder->executeCommand('cd %s && git diff origin/%s "%s"', $path, $this->getBranch(), $file);
     } else {
         $builder->executeCommand('cd %s && git diff %s^! "%s"', $path, $this->getCommitId(), $file);
     }
     $builder->logExecOutput(true);
     $diff = $builder->getLastOutput();
     $helper = new Diff();
     $lines = $helper->getLinePositions($diff);
     return $lines[$line];
 }
예제 #12
0
 /**
  * Uses git diff to figure out what the diff line position is, based on the error line number.
  * @param Builder $builder
  * @param $file
  * @param $line
  * @return int|null
  */
 protected function getDiffLineNumber(Builder $builder, $file, $line)
 {
     $line = (int) $line;
     $builder->logExecOutput(false);
     $prNumber = $this->getExtra('pull_request_number');
     $path = $builder->buildPath;
     if (!empty($prNumber)) {
         $builder->executeCommand('cd %s && git diff origin/%s "%s"', $path, $this->getBranch(), $file);
     } else {
         $commitId = $this->getCommitId();
         $compare = $commitId == 'Manual' ? 'HEAD' : $commitId;
         $builder->executeCommand('cd %s && git diff %s^^ "%s"', $path, $compare, $file);
     }
     $builder->logExecOutput(true);
     $diff = $builder->getLastOutput();
     $helper = new Diff();
     $lines = $helper->getLinePositions($diff);
     return isset($lines[$line]) ? $lines[$line] : null;
 }