Tester\Runner\Job::run PHP Method

run() public method

Runs single test.
public run ( $flags = NULL ) : void
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()
            }
        }
    }

Usage Example

Esempio n. 1
0
 /** @return int|NULL */
 public function run()
 {
     Environment::setupColors();
     Environment::setupErrors();
     ob_start();
     $cmd = $this->loadOptions();
     Environment::$debugMode = (bool) $this->options['--debug'];
     if (isset($this->options['--colors'])) {
         Environment::$useColors = (bool) $this->options['--colors'];
     } elseif (in_array($this->options['-o'], ['tap', 'junit'])) {
         Environment::$useColors = FALSE;
     }
     if ($cmd->isEmpty() || $this->options['--help']) {
         $cmd->help();
         return;
     }
     $this->createPhpInterpreter();
     if ($this->options['--info']) {
         $job = new Job(__DIR__ . '/info.php', $this->interpreter);
         $job->run();
         echo $job->getOutput();
         return;
     }
     if ($this->options['--coverage']) {
         $coverageFile = $this->prepareCodeCoverage();
     }
     $runner = $this->createRunner();
     $runner->setEnvironmentVariable(Environment::RUNNER, 1);
     $runner->setEnvironmentVariable(Environment::COLORS, (int) Environment::$useColors);
     if (isset($coverageFile)) {
         $runner->setEnvironmentVariable(Environment::COVERAGE, $coverageFile);
     }
     if ($this->options['-o'] !== NULL) {
         ob_clean();
     }
     ob_end_flush();
     if ($this->options['--watch']) {
         $this->watch($runner);
         return;
     }
     $result = $runner->run();
     if (isset($coverageFile) && preg_match('#\\.(?:html?|xml)\\z#', $coverageFile)) {
         $this->finishCodeCoverage($coverageFile);
     }
     return $result ? 0 : 1;
 }
All Usage Examples Of Tester\Runner\Job::run