/** * @param Process $process * @param AdapterAbstract $testFrameworkAdapter * @param callable $onProgressCallback * * @return bool */ public function run(Process $process, AdapterAbstract $testFrameworkAdapter, \Closure $onProgressCallback = null) { $hasFailure = false; $process->run(function ($out, $data) use($process, $testFrameworkAdapter, $onProgressCallback, &$hasFailure) { if ($out == Process::ERR) { $hasFailure = true; $process->stop(); return; } if ($hasFailure) { return; } if (!$testFrameworkAdapter->ok($data)) { $hasFailure = true; $process->stop(); return; } $oksCount = $testFrameworkAdapter->hasOks($data); if ($oksCount !== false && $onProgressCallback) { $onProgressCallback($oksCount); } }); $process->stop(); return $hasFailure; }
/** * Runs the current test suite. * @param Container $container * * @return Result */ public function run(Container $container) { $this->onStart(); $hasFailure = $this->performInitialTestsRun($this->process, $this->adapter); $coverage = null; $lineCoverage = 0; if ($this->adapter->ok($this->process->getOutput()) && $this->process->getExitCode() === 0) { /** * Capture headline line coverage %. * Get code coverage data so we can determine which test suites or * or specifications need to be run for each mutation. */ $coverage = $this->adapter->getCoverageData($container); $lineCoverage = $coverage->getLineCoverageFrom($this->coverageLogFile); } $result = new Result($this->process, $hasFailure, $coverage, $lineCoverage); $this->onStop($result); return $result; }
/** * @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; }