#323477: increase simpletest speed. From: Damien Tournoud --- install.core.inc | 5 +++++ install.inc | 1 + simpletest/drupal_web_test_case.php | 23 +++++++++++++++++------ simpletest/tests/database_test.test | 1 + testing/testing.info | 6 ++++++ testing/testing.install | 17 +++++++++++++++++ testing/testing.profile | 3 +++ 7 files changed, 50 insertions(+), 6 deletions(-) create mode 100644 testing/testing.info create mode 100644 testing/testing.install create mode 100644 testing/testing.profile diff --git includes/install.core.inc includes/install.core.inc index 6fe0c4a..1abb3bb 100644 --- includes/install.core.inc +++ includes/install.core.inc @@ -1111,6 +1111,11 @@ function install_select_profile_form($form, &$form_state, $profile_files) { include_once DRUPAL_ROOT . '/' . $profile->uri; $details = install_profile_info($profile->name); + // Don't show hidden profiles. This is used by to hide the testing profile, + // which only exists to speed up test runs. + if ($details['hidden'] === TRUE) { + continue; + } $profiles[$profile->name] = $details; // Determine the name of the profile; default to file name if defined name diff --git includes/install.inc includes/install.inc index c2ba66e..987c4c6 100644 --- includes/install.inc +++ includes/install.inc @@ -1022,6 +1022,7 @@ function install_profile_info($profile, $locale = 'en') { 'description' => '', 'distribution_name' => 'Drupal', 'version' => NULL, + 'hidden' => FALSE, 'php' => DRUPAL_MINIMUM_PHP, ); $info = drupal_parse_info_file("profiles/$profile/$profile.info") + $defaults; diff --git modules/simpletest/drupal_web_test_case.php modules/simpletest/drupal_web_test_case.php index b060c53..bc3cee4 100644 --- modules/simpletest/drupal_web_test_case.php +++ modules/simpletest/drupal_web_test_case.php @@ -622,6 +622,13 @@ class DrupalUnitTestCase extends DrupalTestCase { */ class DrupalWebTestCase extends DrupalTestCase { /** + * The profile to install as a basis for testing. + * + * @var string + */ + protected $profile = 'standard'; + + /** * The URL currently loaded in the internal browser. * * @var string @@ -1193,11 +1200,11 @@ class DrupalWebTestCase extends DrupalTestCase { variable_set('file_private_path', $private_files_directory); variable_set('file_temporary_path', $temp_files_directory); - // Include the default profile. - variable_set('install_profile', 'standard'); - $profile_details = install_profile_info('standard', 'en'); + // Include the testing profile. + variable_set('install_profile', $this->profile); + $profile_details = install_profile_info($this->profile, 'en'); - // Install the modules specified by the default profile. + // Install the modules specified by the testing profile. module_enable($profile_details['dependencies'], FALSE); // Install modules needed for this test. This could have been passed in as @@ -1213,7 +1220,12 @@ class DrupalWebTestCase extends DrupalTestCase { } // Run default profile tasks. - module_enable(array('standard'), FALSE); + $install_profile_module_exists = db_query("SELECT 1 FROM {system} WHERE type = 'module' AND name = :name", array( + ':name' => $this->profile)) + ->fetchField(); + if ($install_profile_module_exists) { + module_enable(array($this->profile), FALSE); + } // Rebuild caches. drupal_static_reset(); @@ -3064,7 +3076,6 @@ class DrupalWebTestCase extends DrupalTestCase { $this->error(l(t('Verbose message'), $url, array('attributes' => array('target' => '_blank'))), 'User notice'); } } - } /** diff --git modules/simpletest/tests/database_test.test modules/simpletest/tests/database_test.test index c6c61df..e6062e5 100644 --- modules/simpletest/tests/database_test.test +++ modules/simpletest/tests/database_test.test @@ -17,6 +17,7 @@ class FakeRecord { } * here. */ class DatabaseTestCase extends DrupalWebTestCase { + protected $profile = 'testing'; function setUp() { parent::setUp('database_test'); diff --git profiles/testing/testing.info profiles/testing/testing.info new file mode 100644 index 0000000..e82e8dc --- /dev/null +++ profiles/testing/testing.info @@ -0,0 +1,6 @@ +; $Id:$ +name = Testing +description = Totally stripped back testing profile. +version = VERSION +core = 7.x +hidden = TRUE diff --git profiles/testing/testing.install profiles/testing/testing.install new file mode 100644 index 0000000..74a1fff --- /dev/null +++ profiles/testing/testing.install @@ -0,0 +1,17 @@ +