Permalink
Browse files

Added the 'error-on-fail' option whereby the 'test' command will exit…

…(-1) if the test fails. This is useful for when running the tests as part of an automated build (e.g. using ANT).
  • Loading branch information...
1 parent da67138 commit d32be2db714eafc96c5d2149d979a2c5a7b5775b @hiddentao committed Jun 10, 2010
Showing with 7 additions and 3 deletions.
  1. +7 −3 simpletest.drush.inc
View
@@ -49,6 +49,7 @@ function simpletest_drush_command() {
'options' => array(
'--detail' => 'Show detailed test output.',
'--color' => 'Use color highlighting for results output.',
+ '--error-on-fail' => 'Exit to console with an error code if the test fails.',
),
'drupal dependencies' => array('simpletest'),
'core' => array('6','7'),
@@ -94,7 +95,7 @@ function drush_simpletest_test_one($test_class='') {
global $verbose, $color;
$verbose = is_null(drush_get_option('detail')) ? FALSE : TRUE;
$color = is_null(drush_get_option('color')) ? FALSE : TRUE;
-
+ $error_on_fail = is_null(drush_get_option('error-on-fail')) ? FALSE : TRUE;
// call this method rather than simpletest_test_get_all() in order to bypass internal cache
$all_test_classes = simpletest_test_get_all_classes();
@@ -148,10 +149,13 @@ function drush_simpletest_test_one($test_class='') {
// Cleanup our test results.
simpletest_clean_results_table($id);
- if ('fail' == $status)
+ if ('fail' == $status) {
drush_print("Test $test_class FAILED!");
+ if ($error_on_fail)
+ exit(-1);
+ }
else
- drush_print("Test $test_class PASSED.");
+ drush_print("Test $test_class PASSED.");
}

0 comments on commit d32be2d

Please sign in to comment.