diff --git a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php index b6df347..5e40936 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/TestBase.php @@ -85,11 +85,18 @@ protected $skipClasses = array(__CLASS__ => TRUE); /** + * Allows run-tests.sh to always override saving simpletest browser output. + * + * @var bool + */ + protected $overrideSimpletestConfigVerbose; + + /** * TRUE if verbose debugging is enabled. * * @var boolean */ - public $verbose; + protected $verbose = FALSE; /** * Incrementing identifier for verbose output filenames. @@ -721,14 +728,9 @@ protected function verbose($message) { */ public function run(array $methods = array()) { TestServiceProvider::$currentTest = $this; - $simpletest_config = \Drupal::config('simpletest.settings'); $class = get_class($this); - // Unless preset from run-tests.sh, retrieve the current verbose setting. - if (!isset($this->verbose)) { - $this->verbose = $simpletest_config->get('verbose'); - } - if ($this->verbose) { + if ($this->verboseBrowserOutput()) { // Initialize verbose debugging. $this->verbose = TRUE; $this->verboseDirectory = PublicStream::basePath() . '/simpletest/verbose'; @@ -740,6 +742,7 @@ public function run(array $methods = array()) { } // HTTP auth settings (:) for the simpletest browser // when sending requests to the test site. + $simpletest_config = \Drupal::config('simpletest.settings'); $this->httpauth_method = (int) $simpletest_config->get('httpauth.method'); $username = $simpletest_config->get('httpauth.username'); $password = $simpletest_config->get('httpauth.password'); @@ -1498,4 +1501,32 @@ public function copyConfig(StorageInterface $source_storage, StorageInterface $t $target_storage->write($name, $source_storage->read($name)); } } + + /** + * Overrides Simpletest configuration to disable or enable verbose browser output. + * + * @param bool $override + * Set to TRUE to enable verbose browser output or FALSE to disable. + */ + public function overrideVerboseBrowserOutput ($override) { + $this->overrideSimpletestConfigVerbose = $override; + } + + /** + * Determines if verbose browser output has been enabled or disabled. + * + * @return bool + * TRUE if verbose browser output is allowed, FALSE otherwise. + */ + protected function verboseBrowserOutput() { + // If the override is set use the value otherwise fallback to the configured + // value. + if (isset($this->overrideSimpletestConfigVerbose)) { + return $this->overrideSimpletestConfigVerbose; + } + else { + return \Drupal::config('simpletest.settings')->get('verbose'); + } + } + } diff --git a/core/scripts/run-tests.sh b/core/scripts/run-tests.sh index 9b1a7bb..a6e85d7 100755 --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -154,6 +154,10 @@ function simpletest_script_help() { --verbose Output detailed assertion messages in addition to summary. + --verbose-browser + + Capture page requests and log them to files/simpletest/verbose. + --keep-results Keeps detailed assertion results (in the database) after tests @@ -211,6 +215,7 @@ function simpletest_script_parse_args() { 'file' => FALSE, 'color' => FALSE, 'verbose' => FALSE, + 'verbose-browser' => FALSE, 'keep-results' => FALSE, 'test_names' => array(), 'repeat' => 1, @@ -498,7 +503,7 @@ function simpletest_script_run_one_test($test_id, $test_class) { $test = new $test_class($test_id); $test->dieOnFail = (bool) $args['die-on-fail']; - $test->verbose = (bool) $args['verbose']; + $test->overrideVerboseBrowserOutput((bool) $args['verbose-browser']); $test->run(); $info = $test->getInfo(); @@ -533,7 +538,7 @@ function simpletest_script_command($test_id, $test_class) { $command .= ' --url ' . escapeshellarg($args['url']); $command .= ' --php ' . escapeshellarg($php); $command .= " --test-id $test_id"; - foreach (array('verbose', 'keep-results', 'color', 'die-on-fail') as $arg) { + foreach (array('verbose', 'verbose-browser', 'keep-results', 'color', 'die-on-fail') as $arg) { if ($args[$arg]) { $command .= ' --' . $arg; }