Skip to content

Commit

Permalink
- Patch #323477 by justinrandell, boombatower, tstoeckler, Damien Tou…
Browse files Browse the repository at this point in the history
…rnoud: increase simpletest speed by running on a simplified profile.
  • Loading branch information
dbuytaert committed Aug 22, 2010
1 parent 260dbda commit 153ef8b
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 7 deletions.
5 changes: 5 additions & 0 deletions includes/install.core.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions includes/install.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
25 changes: 18 additions & 7 deletions modules/simpletest/drupal_web_test_case.php
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,13 @@ protected function tearDown() {
* Test case for typical Drupal tests.
*/
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.
*
Expand Down Expand Up @@ -1193,11 +1200,11 @@ protected function setUp() {
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
Expand All @@ -1212,8 +1219,13 @@ protected function setUp() {
module_enable($modules, TRUE);
}

// Run default profile tasks.
module_enable(array('standard'), FALSE);
// Run the profile tasks.
$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();
Expand Down Expand Up @@ -3064,7 +3076,6 @@ protected function verbose($message) {
$this->error(l(t('Verbose message'), $url, array('attributes' => array('target' => '_blank'))), 'User notice');
}
}

}

/**
Expand Down
1 change: 1 addition & 0 deletions modules/simpletest/tests/database_test.test
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class FakeRecord { }
* here.
*/
class DatabaseTestCase extends DrupalWebTestCase {
protected $profile = 'testing';

function setUp() {
parent::setUp('database_test');
Expand Down
6 changes: 6 additions & 0 deletions profiles/testing/testing.info
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
; $Id$
name = Testing
description = Totally stripped back testing profile.
version = VERSION
core = 7.x
hidden = TRUE
17 changes: 17 additions & 0 deletions profiles/testing/testing.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

/**
* Implements hook_install().
*
* Perform actions to set up the site for this profile.
*/
function testing_install() {

// Allow visitor account creation, but with administrative approval.
variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL);

// Enable default permissions for system roles.
user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access content'));
user_role_grant_permissions(DRUPAL_AUTHENTICATED_RID, array('access content'));
}

3 changes: 3 additions & 0 deletions profiles/testing/testing.profile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
// $Id$

0 comments on commit 153ef8b

Please sign in to comment.