Changeset View
Changeset View
Standalone View
Standalone View
src/unit/engine/ArcanistConfigurationDrivenUnitTestEngine.php
| Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | foreach ($config['engines'] as $name => $spec) { | ||||
| $built_test_engines[] = $test_engine; | $built_test_engines[] = $test_engine; | ||||
| } | } | ||||
| return $built_test_engines; | return $built_test_engines; | ||||
| } | } | ||||
| public function run() { | public function run() { | ||||
| $renderer = $this->renderer; | |||||
| $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) { | ||||
| $paths = array(); | $paths = array(); | ||||
| } | } | ||||
| $engines = $this->buildTestEngines(); | $engines = $this->buildTestEngines(); | ||||
| $results = array(); | $all_results = array(); | ||||
| $exceptions = array(); | $exceptions = array(); | ||||
| foreach ($engines as $engine) { | foreach ($engines as $engine) { | ||||
| $engine | $engine | ||||
| ->setWorkingCopy($this->getWorkingCopy()) | ->setWorkingCopy($this->getWorkingCopy()) | ||||
| ->setEnableCoverage($this->getEnableCoverage()); | ->setEnableCoverage($this->getEnableCoverage()) | ||||
| ->setRenderer($renderer); | |||||
| // TODO: At some point, maybe we should emit a warning here if an engine | // TODO: At some point, maybe we should emit a warning here if an engine | ||||
| // doesn't support `--everything`, to reduce surprise when `--everything` | // doesn't support `--everything`, to reduce surprise when `--everything` | ||||
| // does not really mean `--everything`. | // does not really mean `--everything`. | ||||
| if ($engine->supportsRunAllTests()) { | if ($engine->supportsRunAllTests()) { | ||||
| $engine->setRunAllTests($this->getRunAllTests()); | $engine->setRunAllTests($this->getRunAllTests()); | ||||
| } | } | ||||
| try { | try { | ||||
| // TODO: Type check the results. | // TODO: Type check the results. | ||||
| $results[] = $engine->run(); | $results = $engine->run(); | ||||
| $all_results[] = $results; | |||||
| foreach ($results as $result) { | |||||
| if ($engine->shouldEchoTestResults()) { | |||||
| echo $renderer->renderUnitResult($result); | |||||
| } | |||||
| } | |||||
| } catch (ArcanistNoEffectException $ex) { | } catch (ArcanistNoEffectException $ex) { | ||||
| $exceptions[] = $ex; | $exceptions[] = $ex; | ||||
| } | } | ||||
| } | } | ||||
| if (!$results) { | if (!$all_results) { | ||||
| // If all engines throw an `ArcanistNoEffectException`, then we should | // If all engines throw an `ArcanistNoEffectException`, then we should | ||||
| // preserve this behavior. | // preserve this behavior. | ||||
| throw new ArcanistNoEffectException(pht('No tests to run.')); | throw new ArcanistNoEffectException(pht('No tests to run.')); | ||||
| } | } | ||||
| return array_mergev($results); | return array_mergev($all_results); | ||||
| } | |||||
| public function shouldEchoTestResults() { | |||||
| return false; | |||||
| } | } | ||||
| private function loadAvailableTestEngines() { | private function loadAvailableTestEngines() { | ||||
| return id(new PhutilClassMapQuery()) | return id(new PhutilClassMapQuery()) | ||||
| ->setAncestorClass('ArcanistUnitTestEngine') | ->setAncestorClass('ArcanistUnitTestEngine') | ||||
| ->setUniqueMethod('getEngineConfigurationName', true) | ->setUniqueMethod('getEngineConfigurationName', true) | ||||
| ->execute(); | ->execute(); | ||||
| } | } | ||||
| Show All 39 Lines | |||||