Index: includes/common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/common.inc,v
retrieving revision 1.1239
diff -u -p -r1.1239 common.inc
--- includes/common.inc	9 Oct 2010 08:05:15 -0000	1.1239
+++ includes/common.inc	11 Oct 2010 19:32:34 -0000
@@ -5013,8 +5013,6 @@ function drupal_cron_cleanup() {
 function drupal_system_listing($mask, $directory, $key = 'name', $min_depth = 1) {
   $config = conf_path();
 
-  $profile = drupal_get_profile();
-
   $searchdir = array($directory);
   $files = array();
 
@@ -5022,8 +5020,14 @@ function drupal_system_listing($mask, $d
   // themes as organized by a distribution. It is pristine in the same way
   // that /modules is pristine for core; users should avoid changing anything
   // there in favor of sites/all or sites/<domain> directories.
-  if (file_exists("profiles/$profile/$directory")) {
-    $searchdir[] = "profiles/$profile/$directory";
+  //
+  // For SimpleTest to be able to test modules packaged together with a
+  // distribution we need to include the parent profile's search path.
+  $profiles = array(drupal_get_profile(), variable_get('simpletest_parent_profile', ''));
+  foreach ($profiles as $profile) {
+    if ($profile && file_exists("profiles/$profile/$directory")) {
+      $searchdir[] = "profiles/$profile/$directory";
+    }
   }
 
   // Always search sites/all/* as well as the global directories
Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.240
diff -u -p -r1.240 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	5 Oct 2010 06:17:29 -0000	1.240
+++ modules/simpletest/drupal_web_test_case.php	11 Oct 2010 19:32:34 -0000
@@ -1236,7 +1236,10 @@ class DrupalWebTestCase extends DrupalTe
     variable_set('file_private_path', $private_files_directory);
     variable_set('file_temporary_path', $temp_files_directory);
 
-    // Include the testing profile.
+    // Include the testing profile and set the simpletest_parent_profile
+    // variable which is used to add the parent profile's search path to the
+    // child site's search paths. See drupal_system_listing().
+    variable_set('simpletest_parent_profile', $this->originalProfile);
     variable_set('install_profile', $this->profile);
     $profile_details = install_profile_info($this->profile, 'en');
 
@@ -1402,6 +1405,9 @@ class DrupalWebTestCase extends DrupalTe
       $GLOBALS['conf']['language_default'] = $this->originalLanguageDefault;
     }
 
+    // Delete 'simpletest_parent_profile' variable.
+    variable_del('simpletest_parent_profile');
+
     // Close the CURL handler.
     $this->curlClose();
   }
