public function run() { $srcdir = dirname(__FILE__) . '/../../'; $engine = new WatchmanIntegrationEngine(); $engine->setProjectRoot($srcdir); $paths = $this->getArgument('args'); $results = $engine->run($paths); $failed = 0; $colors = array('pass' => '<fg:green>OK</fg> ', 'fail' => '<fg:red>FAIL</fg>', 'skip' => '<fg:yellow>SKIP</fg>'); foreach ($results as $result) { $res = $result->getResult(); $status = idx($colors, $res, $res); echo phutil_console_format("{$status} %s (%.2fs)\n", $result->getName(), $result->getDuration()); if ($res == 'pass' || $res == 'skip') { continue; } echo $result->getUserData() . "\n"; $failed++; } if (!$failed) { echo phutil_console_format("\nAll %d tests passed/skipped :successkid:\n", count($results)); } else { echo phutil_console_format("\n%d of %d tests failed\n", $failed, count($results)); } return $failed ? 1 : 0; }
public function run() { $srcdir = realpath(dirname(__FILE__) . '/../../'); chdir($srcdir); $engine = new WatchmanIntegrationEngine(); // Hook up to running watchman instance from the python test harness if (getenv('WATCHMAN_SOCK')) { $engine->setWatchmanInstance(new PythonProvidedWatchmanInstance()); } $engine->setProjectRoot($srcdir); $paths = $this->getArgument('args'); $results = $engine->run($paths); $failed = 0; $formats = array('pass' => "ok %d - %s %s\n", 'fail' => "not ok %d - %s %s\n", 'skip' => "ok %d # skip %s %s\n"); printf("1..%d\n", count($results)); foreach ($results as $testno => $result) { $res = $result->getResult(); $format = idx($formats, $res, $res); $output = explode("\n", $result->getUserData()); if ($res == 'fail') { # makes the failed assertions render more nicely $output[] = 'failed '; } $last_line = array_pop($output); if ($output) { echo '# ' . implode("\n# ", $output) . "\n"; } printf($format, $testno + 1, $result->getName(), $last_line); } return $failed ? 1 : 0; }