Index: modules/simpletest/drupal_web_test_case.php =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v retrieving revision 1.11 diff -u -r1.11 drupal_web_test_case.php --- drupal_web_test_case.php 2 Jun 2008 17:39:12 -0000 1.11 +++ drupal_web_test_case.php 3 Jun 2008 20:22:32 -0000 @@ -198,12 +198,13 @@ $form_state['values'] = array('status' => $this->_modules, 'op' => t('Save configuration')); drupal_execute('system_modules', $form_state); - //rebuilding all caches + // Rebuilding all caches drupal_rebuild_theme_registry(); node_types_rebuild(); menu_rebuild(); cache_clear_all('schema', 'cache'); module_rebuild_cache(); + module_list(TRUE); return $this->assertTrue(module_exists($name), t('@name enabled.', array('@name' => $name)), t('Module')); } Index: modules/simpletest/simpletest.module =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.module,v retrieving revision 1.3 diff -u -r1.3 simpletest.module --- simpletest.module 10 May 2008 07:46:22 -0000 1.3 +++ simpletest.module 3 Jun 2008 20:32:46 -0000 @@ -85,7 +85,7 @@ $output = drupal_get_form('simpletest_overview_form'); if (simpletest_running_output()) { - return simpletest_running_output() . $output; + return simpletest_running_output() . drupal_get_form('simpletest_overview_form'); } else { return $output; @@ -94,6 +94,13 @@ function simpletest_running_output($output = NULL) { static $o; + if (isset($_SESSION['simpletest_results'])) { + $o = array_shift($_SESSION['simpletest_results']); + drupal_add_js('misc/collapse.js'); + if (empty($_SESSION['simpletest_results'])) { + unset($_SESSION['simpletest_results']); + } + } if ($output != NULL) { $o = $output; } @@ -280,7 +287,6 @@ drupal_set_message(t('No test has been selected.'), 'error'); } - simpletest_running_output($output); return FALSE; } @@ -387,7 +393,8 @@ static $test_running; if (!$test_running) { $test_running = TRUE; - $test = simpletest_get_total_test($test_list); + $batch = FALSE; + $tests = simpletest_get_total_test($test_list); switch ($reporter) { case 'text': $reporter = &new TextReporter(); @@ -399,26 +406,95 @@ $reporter = &new HtmlReporter(); break; case 'drupal': + $batch = TRUE; $reporter = &new DrupalReporter(); break; } cache_clear_all(); - $results = $test->run($reporter); - $test_running = FALSE; - switch (get_class($reporter)) { - case 'TextReporter': - case 'XMLReporter': - case 'HtmlReporter': - return $results; - case 'DrupalReporter': - return $reporter->getOutput(); + if ($batch) { + $operations = array(); + for ($i = 0; $i < count($tests->_test_cases); $i++) { + $operations[] = array('_simpletest_batch_operation', array(serialize($tests), serialize($reporter))); + } + + $batch = array( + 'title' => t('Running SimpleTests'), + 'operations' => $operations, + 'finished' => '_simpletest_batch_finished', + 'redirect' => 'admin/build/testing', + ); + batch_set($batch); + } + else { + $results = $tests->run($reporter); + $test_running = FALSE; + return $results; } } } /** + * Batch operation callback. + */ +function _simpletest_batch_operation($tests, $reporter, &$context) { + simpletest_get_total_test(); + if (!isset($context['sandbox']['tests'])) { + $tests = unserialize($tests); + } + else { + $tests = unserialize($context['sandbox']['tests']); + } + if (!isset($context['sandbox']['reporter'])) { + $reporter = unserialize($reporter); + } + else { + $reporter = unserialize($context['sandbox']['reporter']); + } + if (empty($context['sandbox'])) { + // Initiate multistep processing. + $context['sandbox']['progress'] = 0; + $context['sandbox']['max'] = count($tests->_test_cases); + } + + $results = $tests->runOnce($reporter); + $context['sandbox']['progress']++; + + switch (get_class($reporter)) { + case 'TextReporter': + case 'XMLReporter': + case 'HtmlReporter': + $result = $results; + case 'DrupalReporter': + $result = $reporter->getOutput(); + } + + $context['sandbox']['reporter'] = serialize($reporter); + $context['sandbox']['tests'] = serialize($tests); + + // Multistep processing : report progress. + if ($context['sandbox']['progress'] != $context['sandbox']['max']) { + $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max']; + } + $context['results'][] = $result; + $context['message'] = 'Test successfully completed.'; +} + +/** + * Batch finished callback. + */ +function _simpletest_batch_finished($success, $results, $operations) { + if ($success) { + $_SESSION['simpletest_results'][] = implode('', $results); + drupal_set_message(t('The tests have finished running.')); + } + else { + drupal_set_message(t('The tests did not successfully finish.'), 'error'); + } +} + +/** * This function makes sure no unnecessary copies of the DrupalTests object are instantiated * @param array $classes list of all classes the test should concern or * DEFAULT NULL @@ -473,5 +549,4 @@ ); return system_settings_form($form); - } Index: modules/simpletest/test_case.php =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/test_case.php,v retrieving revision 1.3 diff -u -r1.3 test_case.php --- test_case.php 10 May 2008 06:55:09 -0000 1.3 +++ test_case.php 3 Jun 2008 17:02:52 -0000 @@ -509,6 +509,20 @@ return $reporter->getStatus(); } + function runOnce(&$reporter) { + $reporter->paintGroupStart($this->getLabel(), $this->getSize()); + $test = array_shift($this->_test_cases); + if (is_string($test)) { + $test = &new $test(); + $test->run($reporter); + } + else { + $test->run($reporter); + } + $reporter->paintGroupEnd($this->getLabel()); + return $reporter->getStatus(); + } + /** * Number of contained test cases. * @return integer Total count of cases in the group.