/** * Returns the command based into the configurations. * * @param array $settings * * @return string */ public function getCommand(array $settings) { $command = $this->runtime->getBinary(); $command .= $this->settingsToParameters($settings); if (true === $this->stderrRedirection) { $command .= ' 2>&1'; } return $command; }
/** * Returns the command based into the configurations. * * @param array $settings * * @return string */ public function getCommand(array $settings) { $command = $this->runtime->getBinary(); $command .= $this->settingsToParameters($settings); if ('phpdbg' === PHP_SAPI) { $command .= ' -qrr ' . escapeshellarg(__DIR__ . '/PHP/eval-stdin.php'); } if (true === $this->stderrRedirection) { $command .= ' 2>&1'; } return $command; }
/** * @param Job $job * @return bool */ public function startJob(Job $job) { $this->pool->add($job); try { $runtime = new Runtime(); $job->start($runtime->getBinary()); } catch (ForkException $e) { $this->pool->remove($job); $job->startTest(); $job->addError($e); $job->endTest(); return false; } $job->startTest(); return true; }
/** * Runs a single job (PHP code) using a separate PHP process. * * @param string $job * @param array $settings * * @return array * * @throws PHPUnit_Framework_Exception */ public function runJob($job, array $settings = []) { $runtime = new Runtime(); $process = proc_open($runtime->getBinary() . $this->settingsToParameters($settings), [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']], $pipes); if (!is_resource($process)) { throw new PHPUnit_Framework_Exception('Unable to spawn worker process'); } $this->process($pipes[0], $job); fclose($pipes[0]); $stdout = stream_get_contents($pipes[1]); fclose($pipes[1]); $stderr = stream_get_contents($pipes[2]); fclose($pipes[2]); proc_close($process); $this->cleanup(); return ['stdout' => $stdout, 'stderr' => $stderr]; }
/** * * {@inheritdoc} Reading from STDOUT or STDERR hangs forever on Windows if the output is * too large. * * @see https://bugs.php.net/bug.php?id=51800 */ public function runJob($job, array $settings = array()) { $runtime = new Runtime(); if (false === ($stdout_handle = tmpfile())) { throw new PHPUnit_Framework_Exception('A temporary file could not be created; verify that your TEMP environment variable is writable'); } $process = proc_open($runtime->getBinary() . $this->settingsToParameters($settings), array(0 => array('pipe', 'r'), 1 => $stdout_handle, 2 => array('pipe', 'w')), $pipes); if (!is_resource($process)) { throw new PHPUnit_Framework_Exception('Unable to spawn worker process'); } $this->process($pipes[0], $job); fclose($pipes[0]); $stderr = stream_get_contents($pipes[2]); fclose($pipes[2]); proc_close($process); rewind($stdout_handle); $stdout = stream_get_contents($stdout_handle); fclose($stdout_handle); $this->cleanup(); return array('stdout' => $stdout, 'stderr' => $stderr); }
/** * @covers \SebastianBergmann\Environment\Runtime::getBinary * * @uses \SebastianBergmann\Environment\Runtime::isHHVM */ public function testBinaryCanBeRetrieved() { $this->assertInternalType('string', $this->env->getBinary()); }
private function getPhpBinary() { $runtime = new Runtime(); return $runtime->getBinary(); }