diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh index 3345015..3b8c00c 100755 --- a/scripts/run-tests.sh +++ b/scripts/run-tests.sh @@ -97,7 +97,9 @@ if ($args['xml']) { } // Cleanup our test results. -simpletest_clean_results_table($test_id); +if (!$args['keep-results']) { + simpletest_clean_results_table($test_id); +} // Test complete, exit. exit; @@ -150,6 +152,11 @@ All arguments are long options. --verbose Output detailed assertion messages in addition to summary. + --keep-results + + Keeps detailed assertion results (in the database) after tests + have completed. By default, assertion results are cleared. + [,[, ...]] One or more tests to be run. By default, these are interpreted @@ -192,6 +199,7 @@ function simpletest_script_parse_args() { 'file' => FALSE, 'color' => FALSE, 'verbose' => FALSE, + 'keep-results' => FALSE, 'test_names' => array(), // Used internally. 'test-id' => 0, @@ -358,10 +366,18 @@ function simpletest_script_execute_batch($test_id, $test_classes) { * Bootstrap Drupal and run a single test. */ function simpletest_script_run_one_test($test_id, $test_class) { + global $args, $conf; + try { // Bootstrap Drupal. drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL); + // Override configuration according to command line parameters. + $conf['simpletest.settings']['verbose'] = $args['verbose']; + $conf['simpletest.settings']['clear_results'] = !$args['keep-results']; + $conf['simpletest_verbose'] = $args['verbose']; + $conf['simpletest_clear_results'] = !$args['keep-results']; + $test = new $test_class($test_id); $test->run(); $info = $test->getInfo(); @@ -391,11 +407,17 @@ function simpletest_script_run_one_test($test_id, $test_class) { function simpletest_script_command($test_id, $test_class) { global $args, $php; - $command = escapeshellarg($php) . ' ' . escapeshellarg('./scripts/' . $args['script']) . ' --url ' . escapeshellarg($args['url']); - if ($args['color']) { - $command .= ' --color'; + $command = escapeshellarg($php) . ' ' . escapeshellarg('./core/scripts/' . $args['script']); + $command .= ' --url ' . escapeshellarg($args['url']); + $command .= ' --php ' . escapeshellarg($php); + $command .= " --test-id $test_id"; + foreach (array('verbose', 'keep-results', 'color') as $arg) { + if ($args[$arg]) { + $command .= ' --' . $arg; + } } - $command .= " --php " . escapeshellarg($php) . " --test-id $test_id --execute-test $test_class"; + // --execute-test and class name needs to come last. + $command .= ' --execute-test ' . escapeshellarg($test_class); return $command; }