Example #1
0
 /**
  * @test
  */
 public function shouldWaitAllTheItems()
 {
     $process = $this->getMockBuilder('\\Symfony\\Component\\Process\\Process')->disableOriginalConstructor()->getMock();
     $process->expects($this->exactly(5))->method('isTerminated')->willReturn(false)->willReturnOnConsecutiveCalls(false, false, false, true);
     $processes = new Processes(array($process));
     $this->assertTrue($processes->wait());
 }
Example #2
0
 public function renderBody(QueueInterface $queue, Processes $processes)
 {
     $errorCount = $processes->countErrors();
     $log = $processes->getReport();
     $count = count($log);
     $tests = array_slice($log, $this->lastIndex, $count, 1);
     foreach ($tests as $report) {
         $this->lastIndex++;
         $processorN = "";
         if (OutputInterface::VERBOSITY_VERY_VERBOSE <= $this->output->getVerbosity()) {
             $str = '%d';
             if ($report->isFirstOnThread()) {
                 $str = "<info>%d</info>";
             }
             $processorN = sprintf($str . "\t", $report->getProcessorNumber());
         }
         $flag = "<info>✔</info>";
         $err = '';
         if (!$report->isSuccessful()) {
             $flag = "<error>✘</error>";
             if (OutputInterface::VERBOSITY_VERY_VERBOSE <= $this->output->getVerbosity()) {
                 $err = $report->getErrorBuffer();
             }
         }
         $remaining = sprintf('%d/%d', $this->lastIndex, $this->messageInTheQueue);
         $time = round($report->getTime() * 1000) . ' ms';
         // add a tab to add some space for longer strings so that the next column doesn't jump
         if (strlen($time) < 8) {
             $time .= "\t";
         }
         $this->output->writeln($processorN . $remaining . "\t" . $flag . "\t" . $time . "\t" . $report->getSuite() . $err);
     }
     $this->lastIndex = $count;
     return $errorCount;
 }
Example #3
0
 private function createProcessesForTheBeforeCommand($range, Processes &$processes = null)
 {
     foreach ($range as $currentChannel) {
         $currentProcessNumber = $this->getCurrentProcessCounter();
         $this->incrementForThisChannel($currentChannel);
         $process = $this->processFactory->createAProcessForACustomCommand($this->beforeCommand, $currentChannel, $currentProcessNumber, $this->isFirstForThisChannel($currentChannel));
         $processes->add($currentChannel, $process);
         $processes->start($currentChannel);
     }
     return true;
 }
Example #4
0
 public function renderBody(QueueInterface $queue, Processes $processes)
 {
     $now = $queue->count();
     $errorCount = $processes->countErrors();
     if ($errorCount > 0) {
         $this->bar->setBarCharacter('<error>=</error>');
         $this->writeMessage(sprintf("<error>%d</error> failures.", $errorCount), 'number');
     }
     if ($this->last != $now) {
         $this->bar->advance($this->last - $now);
     }
     $this->last = $now;
     return $errorCount;
 }
Example #5
0
 /**
  * @test
  */
 public function shouldWaitAllTheItems()
 {
     $process = $this->mockProcessWithExpectation('wait');
     $processes = new Processes(array($process));
     $this->assertTrue($processes->wait());
 }