Changeset View
Changeset View
Standalone View
Standalone View
src/unit/engine/ArcanistConfigurationDrivenUnitTestEngine.php
Show First 20 Lines • Show All 75 Lines • ▼ Show 20 Lines | foreach ($config['engines'] as $name => $spec) { | ||||
$test_engine = clone $test_engines[$type]; | $test_engine = clone $test_engines[$type]; | ||||
} else { | } else { | ||||
// We'll raise an error below about the invalid "type" key. | // We'll raise an error below about the invalid "type" key. | ||||
// TODO: Can we just do the type check first, and simplify this a bit? | // TODO: Can we just do the type check first, and simplify this a bit? | ||||
$test_engine = null; | $test_engine = null; | ||||
} | } | ||||
try { | try { | ||||
// TODO: Perhaps we should emit a warning if child engines re-use keys | |||||
Lint: TODO Comment: This comment has a TODO. | |||||
// from the defaults, since their specs will not be respected. | |||||
PhutilTypeSpec::checkMap( | PhutilTypeSpec::checkMap( | ||||
$spec, | $spec, | ||||
array( | $this->getDefaultEngineOptions() + $test_engine->getEngineOptions()); | ||||
'type' => 'string', | |||||
'include' => 'optional regex | list<regex>', | |||||
'exclude' => 'optional regex | list<regex>', | |||||
)); | |||||
} catch (PhutilTypeCheckException $ex) { | } catch (PhutilTypeCheckException $ex) { | ||||
throw new PhutilProxyException( | throw new PhutilProxyException( | ||||
pht( | pht( | ||||
"Error in parsing '%s' file, for test engine '%s'.", | "Error in parsing '%s' file, for test engine '%s'.", | ||||
'.arcunit', | '.arcunit', | ||||
$name), | $name), | ||||
$ex); | $ex); | ||||
} | } | ||||
if ($all_paths) { | if ($all_paths) { | ||||
$include = (array)idx($spec, 'include', array()); | $include = (array)idx($spec, 'include', array()); | ||||
$exclude = (array)idx($spec, 'exclude', array()); | $exclude = (array)idx($spec, 'exclude', array()); | ||||
$paths = $this->matchPaths( | $paths = $this->matchPaths( | ||||
$all_paths, | $all_paths, | ||||
$include, | $include, | ||||
$exclude); | $exclude); | ||||
$test_engine->setPaths($paths); | $test_engine->setPaths($paths); | ||||
} | } | ||||
// Apply any values found from `getEngineOptions` to the engine | |||||
foreach ($test_engine->getEngineOptions() as $key => $type) { | |||||
$value = idx($spec, $key, ''); | |||||
$test_engine->setOption($key, $value); | |||||
} | |||||
$built_test_engines[] = $test_engine; | $built_test_engines[] = $test_engine; | ||||
} | } | ||||
return $built_test_engines; | return $built_test_engines; | ||||
} | } | ||||
private function getDefaultEngineOptions() { | |||||
return array( | |||||
'type' => 'string', | |||||
'include' => 'optional regex | list<regex>', | |||||
'exclude' => 'optional regex | list<regex>', | |||||
); | |||||
} | |||||
public function run() { | public function run() { | ||||
$renderer = $this->renderer; | $renderer = $this->renderer; | ||||
$this->setRenderer(null); | $this->setRenderer(null); | ||||
$paths = $this->getPaths(); | $paths = $this->getPaths(); | ||||
// If we are running with `--everything` then `$paths` will be `null`. | // If we are running with `--everything` then `$paths` will be `null`. | ||||
if (!$paths) { | if (!$paths) { | ||||
Show All 20 Lines | foreach ($engines as $engine) { | ||||
try { | try { | ||||
// TODO: Type check the results. | // TODO: Type check the results. | ||||
$results = $engine->run(); | $results = $engine->run(); | ||||
$all_results[] = $results; | $all_results[] = $results; | ||||
foreach ($results as $result) { | foreach ($results as $result) { | ||||
// If the proxied engine renders its own test results then there | // If the proxied engine renders its own test results then there | ||||
// is no need to render them again here. | // is no need to render them again here. | ||||
if (!$engine->shouldEchoTestResults()) { | if ($engine->shouldEchoTestResults()) { | ||||
echo $renderer->renderUnitResult($result); | echo $renderer->renderUnitResult($result); | ||||
} | } | ||||
} | } | ||||
} catch (ArcanistNoEffectException $ex) { | } catch (ArcanistNoEffectException $ex) { | ||||
$exceptions[] = $ex; | $exceptions[] = $ex; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 58 Lines • Show Last 20 Lines |
This comment has a TODO.