/** * Runs all tests. * @return bool */ public function run() { foreach ($this->outputHandlers as $handler) { $handler->begin(); } $this->results = array(self::PASSED => 0, self::SKIPPED => 0, self::FAILED => 0); $this->jobs = $running = array(); foreach ($this->paths as $path) { $this->findTests($path); } while ($this->jobs || $running) { for ($i = count($running); $this->jobs && $i < $this->jobCount; $i++) { $running[] = $job = array_shift($this->jobs); $job->run($this->jobCount <= 1 || count($running) + count($this->jobs) <= 1); } if (count($running) > 1) { usleep(self::RUN_USLEEP); // stream_select() doesn't work with proc_open() } foreach ($running as $key => $job) { if (!$job->isRunning()) { $this->testHandler->assess($job); unset($running[$key]); } } } foreach ($this->outputHandlers as $handler) { $handler->end(); } return !$this->results[self::FAILED]; }
/** * Runs all tests. * @return bool */ public function run() { $this->interrupted = FALSE; foreach ($this->outputHandlers as $handler) { $handler->begin(); } $this->results = array(self::PASSED => 0, self::SKIPPED => 0, self::FAILED => 0); $this->jobs = $running = array(); foreach ($this->paths as $path) { $this->findTests($path); } $this->jobCount = count($this->jobs) + array_sum($this->results); $this->installInterruptHandler(); while (($this->jobs || $running) && !$this->isInterrupted()) { for ($i = count($running); $this->jobs && $i < $this->threadCount; $i++) { $running[] = $job = array_shift($this->jobs); $async = $this->threadCount > 1 && count($running) + count($this->jobs) > 1; $job->run($async ? $job::RUN_ASYNC : NULL); } if (count($running) > 1) { usleep(Job::RUN_USLEEP); // stream_select() doesn't work with proc_open() } foreach ($running as $key => $job) { if ($this->isInterrupted()) { break 2; } if (!$job->isRunning()) { $this->testHandler->assess($job); unset($running[$key]); } } } $this->removeInterruptHandler(); foreach ($this->outputHandlers as $handler) { $handler->end(); } return !$this->results[self::FAILED]; }