Skip to content
Snippets Groups Projects
Commit 0aa731a7 authored by Angie Byron's avatar Angie Byron
Browse files

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