Index: drupal_web_test_case.php =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v retrieving revision 1.13 diff -u -r1.13 drupal_web_test_case.php --- drupal_web_test_case.php 3 Jun 2008 19:53:42 -0000 1.13 +++ drupal_web_test_case.php 3 Jun 2008 22:49:28 -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: 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 22:49:28 -0000 @@ -82,10 +82,14 @@ simpletest_load(); drupal_add_css(drupal_get_path('module', 'simpletest') . '/simpletest.css', 'module'); drupal_add_js(drupal_get_path('module', 'simpletest') . '/simpletest.js', 'module'); - $output = drupal_get_form('simpletest_overview_form'); - if (simpletest_running_output()) { - return simpletest_running_output() . $output; + $output = drupal_get_form('simpletest_overview_form'); + + if (isset($_SESSION['simpletest_reporter'])) { + $reporter = unserialize($_SESSION['simpletest_reporter']); + $output = $reporter->getOutput() . drupal_get_form('simpletest_overview_form'); + unset($_SESSION['simpletest_reporter']); + return $output; } else { return $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,75 @@ $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(); + $operations[] = array('_simpletest_batch_init', array(serialize($reporter))); + foreach($test_list as $test) { + $operations[] = array('_simpletest_batch_operation', array($test)); + } + + $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 init. + */ +function _simpletest_batch_init($reporter, &$context) { + $context['results'][] = $reporter; + $context['message'] = t('End of initialization'); + error_log("*** Batch initialization: context = " . serialize($context)); +} + +/** + * Batch operation callback. + */ +function _simpletest_batch_operation($test, &$context) { + $tests = &simpletest_get_total_test(array($test)); + $results = $context['results']; + $reporter = unserialize(array_pop($results)); + error_log("*** Batch operation: $test, context = " . serialize($context)); + + $test_results = $tests->run($reporter); + + $context['message'] = t('Processed test %test', array('%test' => $test)); + $results[] = serialize($reporter); + $context['results'] = $results; +} + +/** + * Batch finished callback. + */ +function _simpletest_batch_finished($success, $results, $operations) { + $_SESSION['simpletest_reporter'] = array_pop($results); + if ($success) { + 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