/** * Runs single test. * @param int RUN_ASYNC | RUN_COLLECT_ERRORS * @return void */ public function run($flags = NULL) { foreach ($this->envVars as $name => $value) { putenv("{$name}={$value}"); } $this->proc = proc_open($this->interpreter->getCommandLine() . ' -d register_argc_argv=on ' . Helpers::escapeArg($this->file) . ' ' . implode(' ', $this->args), [['pipe', 'r'], ['pipe', 'w'], ['pipe', 'w']], $pipes, dirname($this->file), NULL, ['bypass_shell' => TRUE]); foreach (array_keys($this->envVars) as $name) { putenv($name); } list($stdin, $this->stdout, $stderr) = $pipes; fclose($stdin); if ($flags & self::RUN_COLLECT_ERRORS) { $this->stderr = $stderr; } else { fclose($stderr); } if ($flags & self::RUN_ASYNC) { stream_set_blocking($this->stdout, 0); // on Windows does not work with proc_open() if ($this->stderr) { stream_set_blocking($this->stderr, 0); } } else { while ($this->isRunning()) { usleep(self::RUN_USLEEP); // stream_select() doesn't work with proc_open() } } }
/** * Runs single test. * @param int RUN_ASYNC | RUN_COLLECT_ERRORS * @return void */ public function run($flags = NULL) { putenv(Environment::RUNNER . '=1'); putenv(Environment::COLORS . '=' . (int) Environment::$useColors); $this->proc = proc_open($this->interpreter->getCommandLine() . ' -n -d register_argc_argv=on ' . \Tester\Helpers::escapeArg($this->file) . ' ' . implode(' ', $this->args), array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w')), $pipes, dirname($this->file), NULL, array('bypass_shell' => TRUE)); list($stdin, $this->stdout, $stderr) = $pipes; fclose($stdin); if ($flags & self::RUN_COLLECT_ERRORS) { $this->stderr = $stderr; } else { fclose($stderr); } if ($flags & self::RUN_ASYNC) { stream_set_blocking($this->stdout, 0); // on Windows does not work with proc_open() if ($this->stderr) { stream_set_blocking($this->stderr, 0); } } else { while ($this->isRunning()) { usleep(self::RUN_USLEEP); // stream_select() doesn't work with proc_open() } } }
/** @return string */ private function prepareCodeCoverage() { if (!$this->interpreter->canMeasureCodeCoverage()) { $alternative = PHP_VERSION_ID >= 70000 ? ' or phpdbg SAPI' : ''; throw new \Exception("Code coverage functionality requires Xdebug extension{$alternative} (used {$this->interpreter->getCommandLine()})"); } file_put_contents($this->options['--coverage'], ''); $file = realpath($this->options['--coverage']); echo "Code coverage: {$file}\n"; return $file; }
/** @return string */ private function prepareCodeCoverage() { if (!$this->interpreter->hasXdebug()) { throw new \Exception("Code coverage functionality requires Xdebug extension (used {$this->interpreter->getCommandLine()})"); } file_put_contents($this->options['--coverage'], ''); $file = realpath($this->options['--coverage']); putenv(Environment::COVERAGE . '=' . $file); echo "Code coverage: {$file}\n"; if (preg_match('#\\.html?\\z#', $file)) { return $file; } }
/** @return string */ private function prepareCodeCoverage() { if (!$this->interpreter->hasXdebug()) { $alternative = PHP_VERSION_ID >= 70000 ? ' or phpdbg SAPI' : ''; throw new \Exception("Code coverage functionality requires Xdebug extension{$alternative} (used {$this->interpreter->getCommandLine()})"); } file_put_contents($this->options['--coverage'], ''); $file = realpath($this->options['--coverage']); putenv(Environment::COVERAGE . '=' . $file); echo "Code coverage: {$file}\n"; if (preg_match('#\\.(?:html?|xml)\\z#', $file)) { return $file; } }