Index: includes/registry.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/registry.inc,v
retrieving revision 1.13
diff -u -r1.13 registry.inc
--- includes/registry.inc	3 Apr 2009 17:41:32 -0000	1.13
+++ includes/registry.inc	1 May 2009 23:21:12 -0000
@@ -41,7 +41,8 @@
   _registry_get_resource_name();
   // Get the list of files we are going to parse.
   $files = array();
-  foreach (module_rebuild_cache() as $module) {
+  $module_cache = module_rebuild_cache();
+  foreach ($module_cache as $module) {
     if ($module->status) {
       $dir = dirname($module->filepath);
       foreach ($module->info['files'] as $file) {
@@ -53,6 +54,10 @@
     $files["$filename"] = array('module' => '', 'weight' => 0);
   }
 
+  // Allow modules to manual add files for disabled modules. The $module_cache
+  // provides the info file information containing the list of files.
+  drupal_alter('registry_files', $files, $module_cache);
+
   foreach (registry_get_parsed_files() as $filename => $file) {
     // Add the md5 to those files we've already parsed.
     if (isset($files[$filename])) {
Index: modules/system/system.api.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.api.php,v
retrieving revision 1.31
diff -u -r1.31 system.api.php
--- modules/system/system.api.php	28 Apr 2009 00:27:06 -0000	1.31
+++ modules/system/system.api.php	1 May 2009 23:21:13 -0000
@@ -1693,5 +1693,46 @@
 }
 
 /**
+ * Perform necessary alterations the list of files parsed by the registry.
+ *
+ * Modules can manually add files from disabled modules, but the files should
+ * be mentioned in the disabled module's info file and added from
+ * $module_cache.
+ *
+ * @param $files
+ *   List of files found in each enabled module's info file. The arrary is
+ *   keyed by the file path and contains an array of the related module name
+ *   and weight.
+ *
+ *   For example:
+ *   @code
+ *     $files["modules/system/system.module"] = array(
+ *       'module' => 'system',
+ *       'weight' => 0,
+ *     );
+ *   @endcode
+ * @param $module_cache
+ *   List of modules returned from module_rebuild_cache().
+ *
+ * @see _registry_rebuild()
+ * @see module_rebuild_cache().
+ * @see simpletest_registry_files_alter()
+ */
+function hook_registry_files_alter($files, $module_cache) {
+  foreach ($module_cache as $module) {
+    // Only add test files for disabled modules, as enabled modules should
+    // already include any test files they provide.
+    if (!$module->status) {
+      $dir = dirname($module->filepath);
+      foreach ($module->info['files'] as $file) {
+        if (preg_match('/.*?\.test/', $file)) {
+          $files["$dir/$file"] = array('module' => $module->name, 'weight' => $module->weight);
+        }
+      }
+    }
+  }
+}
+
+/**
  * @} End of "addtogroup hooks".
  */
