mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 00:32:41 +01:00
Use PhutilAggregateException to aggregate unit test exceptions
Summary: Currently, a shutdown exception ("script exited with open transactions!") overwhelms the actual test failure exception, which is the one that needs to be fixed. Test Plan: Ran a fixture test which opens a transaction and then throws. Got diagnostically useful output after this patch. Reviewers: vrana, btrahan Reviewed By: vrana CC: aran Differential Revision: https://secure.phabricator.com/D3780
This commit is contained in:
parent
10653d7ff3
commit
538115bd0e
1 changed files with 16 additions and 5 deletions
|
@ -421,19 +421,30 @@ abstract class ArcanistPhutilTestCase {
|
|||
$this->willRunOneTest($name);
|
||||
|
||||
$this->beginCoverage();
|
||||
$test_exception = null;
|
||||
$exceptions = array();
|
||||
try {
|
||||
call_user_func_array(
|
||||
array($this, $name),
|
||||
array());
|
||||
$this->passTest(pht('%d assertion(s) passed.', $this->assertions));
|
||||
} catch (Exception $ex) {
|
||||
$test_exception = $ex;
|
||||
$exceptions['Execution'] = $ex;
|
||||
}
|
||||
|
||||
$this->didRunOneTest($name);
|
||||
if ($test_exception) {
|
||||
throw $test_exception;
|
||||
try {
|
||||
$this->didRunOneTest($name);
|
||||
} catch (Exception $ex) {
|
||||
$exceptions['Shutdown'] = $ex;
|
||||
}
|
||||
|
||||
if ($exceptions) {
|
||||
if (count($exceptions) == 1) {
|
||||
throw head($exceptions);
|
||||
} else {
|
||||
throw new PhutilAggregateException(
|
||||
"Multiple exceptions were raised during test execution.",
|
||||
$exceptions);
|
||||
}
|
||||
}
|
||||
} catch (ArcanistPhutilTestTerminatedException $ex) {
|
||||
// Continue with the next test.
|
||||
|
|
Loading…
Reference in a new issue