Commit 0aa731a7 authored by webchick's avatar webchick

Issue #1825592 follow-up by sun, alexpott: Clean-ups to --repeat and...

Issue #1825592 follow-up by sun, alexpott: Clean-ups to --repeat and --die-on-fail capabilities in run-tests.sh.
parent 48af7da2
clear_results: '1'
die_on_fail: '0'
httpauth:
method: '1'
password: ''
......
......@@ -144,11 +144,13 @@ abstract class TestBase {
protected $originalSettings;
/**
* TRUE if die on fail enabled.
* Whether to die in case any test assertion fails.
*
* @see run-tests.sh
*
* @var boolean
*/
protected $dieOnFail = FALSE;
public $dieOnFail = FALSE;
/**
* Constructor for Test.
......@@ -174,7 +176,7 @@ protected function checkRequirements() {
* Internal helper: stores the assert.
*
* @param $status
* Can be 'pass', 'fail', 'exception'.
* Can be 'pass', 'fail', 'exception', 'debug'.
* TRUE is a synonym for 'pass', FALSE for 'fail'.
* @param $message
* (optional) A message to display with the assertion. Do not translate
......@@ -230,7 +232,7 @@ protected function assert($status, $message = '', $group = 'Other', array $calle
return TRUE;
}
else {
if ($this->dieOnFail) {
if ($this->dieOnFail && ($status == 'fail' || $status == 'exception')) {
exit(1);
}
return FALSE;
......@@ -670,7 +672,6 @@ public function run(array $methods = array()) {
}
$this->verboseClassName = str_replace("\\", "_", $class);
}
$this->dieOnFail = $simpletest_config->get('die_on_fail');
// HTTP auth settings (<username>:<password>) for the simpletest browser
// when sending requests to the test site.
$this->httpauth_method = (int) $simpletest_config->get('httpauth.method');
......
......@@ -69,8 +69,8 @@
simpletest_script_reporter_init();
// Execute tests.
for($test_run = 0; $test_run < $args['repeat']; $test_run++) {
simpletest_script_execute_batch(simpletest_script_get_test_list());
for ($i = 0; $i < $args['repeat']; $i++) {
simpletest_script_execute_batch($test_list);
}
// Stop the timer.
......@@ -152,9 +152,10 @@ function simpletest_script_help() {
--die-on-fail
Exit out of php execution immediately on fail. This allows user to
change settings.php to use simpletest created databases and debug
failure. This is often used with repeat to find random failures.
Exit test execution immediately upon any failed assertion. This
allows to access the test site by changing settings.php to use the
test database and configuration directories. Use in combination
with --repeat for debugging random test failures.
<test1>[,<test2>[,<test3> ...]]
......@@ -212,9 +213,6 @@ function simpletest_script_parse_args() {
// Override with set values.
$args['script'] = basename(array_shift($_SERVER['argv']));
// Provide a default for repeat argument.
$args['repeat'] = 1;
$count = 0;
while ($arg = array_shift($_SERVER['argv'])) {
if (preg_match('/--(\S+)/', $arg, $matches)) {
......@@ -368,7 +366,9 @@ function simpletest_script_execute_batch($test_classes) {
$public_files = variable_get('file_public_path', conf_path() . '/files');
$test_directory = $public_files . '/simpletest/' . substr($db_prefix, 10);
echo 'Simpletest database and files kept and test exited immediately on fail so should be reproducible if you change settings.php to use the database prefix '. $db_prefix . ' and config directories in '. $test_directory . "\n";
exit();
$args['keep-results'] = TRUE;
// Exit repeat loop immediately.
$args['repeat'] = -1;
}
}
// Free-up space by removing any potentially created resources.
......@@ -398,9 +398,9 @@ function simpletest_script_run_one_test($test_id, $test_class) {
// Override configuration according to command line parameters.
$conf['simpletest.settings']['verbose'] = $args['verbose'];
$conf['simpletest.settings']['clear_results'] = !$args['keep-results'];
$conf['simpletest.settings']['die_on_fail'] = $args['die-on-fail'];
$test = new $test_class($test_id);
$test->dieOnFail = (bool) $args['die-on-fail'];
$test->run();
$info = $test->getInfo();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment