diff --git a/includes/bootstrap.inc b/includes/bootstrap.inc index 80563ef..80a7b5a 100644 --- a/includes/bootstrap.inc +++ b/includes/bootstrap.inc @@ -2444,6 +2444,23 @@ function drupal_get_bootstrap_phase() { } /** + * Returns whether a simpletest is running or peparing to run. + * + * @param $set + * Set whether a test is running. + * + * @return + * TRUE if test is running, false otherwise. + */ +function drupal_test_running($set = NULL) { + static $test_running = NULL; + if (isset($set)) { + $test_running = $set; + } + return isset($test_running) ? $test_running : (bool)drupal_valid_test_ua(); +} + +/** * Returns the test prefix if this is an internal request from SimpleTest. * * @return diff --git a/includes/common.inc b/includes/common.inc index 31923f2..b722db2 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -5363,7 +5363,7 @@ function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1) // For SimpleTest to be able to test modules packaged together with a // distribution we need to include the profile of the parent site (in which // test runs are triggered). - if (drupal_valid_test_ua()) { + if (drupal_test_running()) { $testing_profile = variable_get('simpletest_parent_profile', FALSE); if ($testing_profile && $testing_profile != $profile) { $profiles[] = $testing_profile; diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php index 0853c7d..74acb13 100644 --- a/modules/simpletest/drupal_web_test_case.php +++ b/modules/simpletest/drupal_web_test_case.php @@ -1419,6 +1419,8 @@ class DrupalWebTestCase extends DrupalTestCase { if (!$this->setupEnvironment) { return FALSE; } + // Indicate a test is preparing/running. + drupal_test_running(TRUE); // Reset all statics and variables to perform tests in a clean environment. $conf = array();