예제 #1
0
파일: Text.php 프로젝트: shadowhand/humbug
 /**
  * @param Result $result
  * @return string
  */
 public function prepareReportForMutant(Result $result)
 {
     $mutant = $result->getMutant();
     $mutation = $mutant->getMutation();
     $out = $mutation->getMutator() . PHP_EOL . 'Diff on ' . $mutation->getClass() . '::' . $mutation->getMethod() . '() in ' . $mutation->getFile() . ':' . PHP_EOL . $mutant->getDiff() . PHP_EOL . PHP_EOL;
     $errorOutput = $result->getErrorOutput();
     if (!empty($errorOutput)) {
         $out .= 'The following output was received on stderr:' . PHP_EOL . PHP_EOL . $errorOutput . PHP_EOL . PHP_EOL;
     }
     return $out;
 }
예제 #2
0
 /**
  * Collects a mutant result.
  *
  * @param Result $result
  */
 public function collect(Result $result)
 {
     $this->totalCount++;
     if ($result->isTimeout()) {
         $this->timeoutCount++;
         $this->timeouts[] = $result;
     } elseif ($result->isError()) {
         $this->errorCount++;
         $this->errors[] = $result;
     } elseif ($result->isKill()) {
         $this->killedCount++;
         $this->killed[] = $result;
     } else {
         $this->escapeCount++;
         $this->escaped[] = $result;
     }
 }
예제 #3
0
파일: Text.php 프로젝트: shadowhand/humbug
 /**
  * Render a progress marker:
  *  T: The test run timed out, possibly due to an infinite loop or underestimated timeout
  *  E: The test run hit a fatal error, either kicked out from a test or due to a Humbug issue
  *  M: The test run was successful. The mutation went undetected by the unit tests.
  *  .: The test run included a fail condition. The mutation was detected!!!
  *
  * @param MutantResult $result
  * @param int $count
  * @param int $current
  * @param int $eolInterval
  */
 public function renderProgressMark(MutantResult $result, $count, $current, $eolInterval = 60)
 {
     $this->progressCount++;
     switch ($result->getResult()) {
         case MutantResult::TIMEOUT:
             $this->write('<fg=cyan;options=bold>T</fg=cyan;options=bold>', false);
             break;
         case MutantResult::ERROR:
             $this->write('<fg=yellow;options=bold>E</fg=yellow;options=bold>', false);
             break;
         case MutantResult::ESCAPE:
             $this->write('<fg=red;options=bold>M</fg=red;options=bold>', false);
             break;
         case MutantResult::KILL:
         default:
             $this->write('<options=bold>.</options=bold>', false);
             break;
     }
     if ($this->progressCount % $eolInterval == 0) {
         $counter = str_pad($this->progressCount, 5, ' ', STR_PAD_LEFT);
         $this->write(' |' . $counter . ' (' . str_pad($current, strlen($count), ' ', STR_PAD_LEFT) . '/' . $count . ')' . PHP_EOL, false);
     }
 }
예제 #4
0
 /**
  * @return Result
  */
 public function getResult()
 {
     if ($this->resultProcessed) {
         throw new RuntimeException('Result has already been processed.');
     }
     /**
      * Exit Code should be 0, 1, 2 or a larger integer.
      * The exit code 0 indicates no problem, should be an escaped mutant
      * detected by checkout the out.
      * Exit codes 1 and 2 indicate failures in the test framework, should
      * be caught mutants.
      * Other exit codes should arise on non-associated errors.
      */
     $status = Result::getStatusCode($this->adapter->ok($this->process->getOutput()), $this->process->getExitCode(), $this->isTimeout);
     $result = new Result($this->mutant, $status, $this->process->getOutput(), $this->process->getErrorOutput());
     $this->process->clearOutput();
     $this->resultProcessed = true;
     return $result;
 }