/**
* 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()
}
}
}