diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh index 01974c5..b91a784 100755 --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -503,7 +503,8 @@ function simpletest_script_setup_database($new = FALSE) { function simpletest_script_execute_batch($test_classes) { global $args, $test_ids; - $exit_code = 0; + // Keeps track of failures or exceptions during the tests. + $has_fails_or_exceptions = FALSE; // Multi-process execution. $children = array(); @@ -522,6 +523,9 @@ function simpletest_script_execute_batch($test_classes) { // to fork for them. if (is_subclass_of($test_class, 'Drupal\Tests\UnitTestCase')) { $exit_code = simpletest_script_run_phpunit($test_id, $test_class); + if ($exit_code) { + $has_fails_or_exceptions = TRUE; + } continue; } @@ -553,7 +557,7 @@ function simpletest_script_execute_batch($test_classes) { // The child exited, unregister it. proc_close($child['process']); if ($status['exitcode']) { - $exit_code = $status['exitcode']; + $has_fails_or_exceptions = TRUE; echo 'FATAL ' . $child['class'] . ': test runner returned a non-zero error code (' . $status['exitcode'] . ').' . "\n"; if ($args['die-on-fail']) { list($db_prefix, ) = simpletest_last_test_get($child['test_id']); @@ -574,7 +578,9 @@ function simpletest_script_execute_batch($test_classes) { } } } - exit($exit_code); + if ($has_fails_or_exceptions) { + return SIMPLETEST_SCRIPT_FAILS_OR_ERRORS; + } } /** @@ -621,7 +627,7 @@ function simpletest_script_run_phpunit($test_id, $class) { $exit_code = SIMPLETEST_SCRIPT_FAILS_OR_ERRORS; } } - exit($exit_code); + return($exit_code); } /**