예제 #1
0
 public function toArray()
 {
     $data = $this->mutant->toArray();
     $data['stderr'] = $this->stdErr;
     $data['stdout'] = $this->stdOut;
     return $data;
 }
예제 #2
0
 /**
  * @param Collector $collector
  * @param CoverageData $coverage
  * @param array $batch
  */
 private function runBatch(Collector $collector, CoverageData $coverage, array $batch, IncrementalCache $cache = null)
 {
     $processes = [];
     foreach ($batch as $batchItem) {
         list($index, $mutation) = $batchItem;
         try {
             $coverage->loadCoverageFor($mutation->getFile());
             /**
              * Unleash the Mutant!
              */
             $mutant = new Mutant($mutation, $this->mutantGenerator, $coverage, $this->baseDirectory);
             if (!$mutant->hasTests()) {
                 throw new NoCoveringTestsException('Current mutant has no covering tests');
             }
             if (!is_null($cache)) {
                 $hit = $this->runCache($cache, $coverage, $collector, $mutation->getFile(), $index);
                 if ($hit === true) {
                     continue;
                 }
             }
             $processes[] = $this->processBuilder->build($mutant, $index);
         } catch (NoCoveringTestsException $e) {
             $shadow = new Mutant($mutation, $this->mutantGenerator, $coverage, $this->baseDirectory);
             $collector->collectShadow($shadow);
             $this->onShadowMutant($index);
         }
     }
     /**
      * Check if the whole batch has been eliminated as uncovered
      * by any tests
      */
     if (count($processes) == 0) {
         return;
     }
     $group = new ParallelGroup($processes);
     $group->run();
     foreach ($processes as $process) {
         /**
          * Handle the defined result for each process
          */
         $result = $process->getResult();
         $this->onMutantDone($result, $process->getMutableIndex());
         $collector->collect($result);
     }
 }
예제 #3
0
 /**
  * Creates a new process to run mutant tests
  * @param Mutant $mutant
  * @param int $index Index of the mutable file in test suite
  *
  * @return Process
  */
 public function build(Mutant $mutant, $index)
 {
     $process = $this->adapter->getProcess($this->container, false, $mutant->getMutation()->getFile(), $mutant->getFile(), $mutant->getTests());
     return new Process($this->adapter, $mutant, $process, $index);
 }