/** @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; }
/** @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 ($this->options['-o'] === 'tap') { 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(); if ($this->options['-o'] !== NULL) { ob_clean(); } ob_end_flush(); if ($this->options['--watch']) { $this->watch($runner); return; } $result = $runner->run(); if (isset($coverageFile)) { $this->finishCodeCoverage($coverageFile); } return $result ? 0 : 1; }