diff -u b/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module --- b/core/modules/simpletest/simpletest.module +++ b/core/modules/simpletest/simpletest.module @@ -134,6 +134,9 @@ // Clear out the previous verbose files. file_unmanaged_delete_recursive('public://simpletest/verbose'); + // Prime module data. + simpletest_prepare_module_data(); + // Get the info for the first test being run. $first_test = array_shift($test_list); $first_instance = new $first_test(); @@ -388,15 +391,19 @@ */ function simpletest_classloader_register($module_data = NULL) { if (!$module_data) { - $module_data = system_rebuild_module_data(); + // This is only needed to register namespaces and it is safe to + // re-register existing namespaces so go with raw data. + $module_data = _system_rebuild_module_data('simpletest_module_data'); } foreach ($module_data as $name => $data) { - if (!$data->status) { - drupal_classloader_register($name, dirname($data->filename)); - } + drupal_classloader_register($name, dirname($data->filename)); } } +function simpletest_prepare_module_data() { + _system_rebuild_module_data('simpletest_module_data', TRUE); +} + /** * Generate test file. */ diff -u b/core/modules/system/system.module b/core/modules/system/system.module --- b/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -2636,21 +2636,19 @@ * @return * An associative array of module information. */ -function _system_rebuild_module_data() { +function _system_rebuild_module_data($state_name = FALSE, $save = FALSE) { static $module_store = array(), $profiles_seen; $profile = drupal_get_profile(); // Find modules not yet processed. $modules = array(); - // If this is the first time, start with all modules. - if (empty($module_store)) { + if (empty($module_store) && ($state_name || drupal_valid_test_ua()) && ($data = state()->get($state_name ?: __FUNCTION__))) { // During a test run no modules can move, no info files can change so // speed up test runs by only finding and parsing once. - if (drupal_valid_test_ua() && ($data = state()->get(__FUNCTION__))) { - $module_store = $data['module_store']; - $profiles_seen = $data['profiles_seen']; - } + $module_store = $data['module_store']; + $profiles_seen = $data['profiles_seen']; } + // If this is the first time, start with all modules. if (empty($module_store)) { // Find modules and installation profiles. As these are files, they can't // change within a request. However, it does depend on $profile. @@ -2716,12 +2714,12 @@ } // Store the processed modules. $module_store += $modules; - if (drupal_valid_test_ua()) { - state()->set(__FUNCTION__, array( - 'module_store' => $module_store, - 'profiles_seen' => $profiles_seen, - )); - } + } + if ($save || ($modules && drupal_valid_test_ua())) { + state()->set($state_name ?: __FUNCTION__, array( + 'module_store' => $module_store, + 'profiles_seen' => $profiles_seen, + )); } $modules = $module_store; // Do not return the non-active profile modules. Typically at most one: when only in patch2: unchanged: --- a/core/scripts/run-tests.sh +++ b/core/scripts/run-tests.sh @@ -68,6 +68,9 @@ drupal_set_time_limit(0); simpletest_script_reporter_init(); +// Prime module data. +simpletest_prepare_module_data(); + // Execute tests. simpletest_script_execute_batch(simpletest_script_get_test_list());