Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:facebook/arcanist
Browse files Browse the repository at this point in the history
  • Loading branch information
csilvers committed Jul 2, 2015
2 parents 55fbc33 + d54cb07 commit cee19d4
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/workflow/ArcanistUnitWorkflow.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ public function run() {
}

$results = $this->engine->run();

$this->validateUnitEngineResults($this->engine, $results);

$this->testResults = $results;

$console = PhutilConsole::getConsole();
Expand Down Expand Up @@ -368,4 +371,42 @@ private function getOutputFormat() {
return idx($known_formats, $format, 'full');
}


/**
* Raise a tailored error when a unit test engine returns results in an
* invalid format.
*
* @param ArcanistUnitTestEngine The engine.
* @param wild Results from the engine.
*/
private function validateUnitEngineResults(
ArcanistUnitTestEngine $engine,
$results) {

if (!is_array($results)) {
throw new Exception(
pht(
'Unit test engine (of class "%s") returned invalid results when '.
'run (with method "%s"). Expected a list of "%s" objects as results.',
get_class($engine),
'run()',
'ArcanistUnitTestResult'));
}

foreach ($results as $key => $result) {
if (!($result instanceof ArcanistUnitTestResult)) {
throw new Exception(
pht(
'Unit test engine (of class "%s") returned invalid results when '.
'run (with method "%s"). Expected a list of "%s" objects as '.
'results, but value with key "%s" is not valid.',
get_class($engine),
'run()',
'ArcanistUnitTestResult',
$key));
}
}

}

}

0 comments on commit cee19d4

Please sign in to comment.