Index: simpletest.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/simpletest/simpletest.module,v retrieving revision 1.41 diff -u -r1.41 simpletest.module --- simpletest.module 3 Apr 2008 19:57:15 -0000 1.41 +++ simpletest.module 5 Apr 2008 16:33:01 -0000 @@ -217,6 +217,25 @@ function simpletest_run_tests($testlist = NULL, $reporter = 'drupal') { static $test_running; if (!$test_running) { + $file = drupal_get_path('module', 'simpletest') .'/spikephpcoverage'; + $coverage = (file_exists($file) && is_dir($file)); + if ($coverage) { + if (!defined('PHPCOVERAGE_HOME')) { + define('PHPCOVERAGE_HOME', $file .'/src'); + } + + require_once PHPCOVERAGE_HOME .'/CoverageRecorder.php'; + require_once PHPCOVERAGE_HOME .'/reporter/HtmlCoverageReporter.php'; + + $coverage_reporter = new HtmlCoverageReporter("Code Coverage Report", '', drupal_get_path('module', 'simpletest') .'/coverage_results/'. time()); + + $includePaths = array('.'); + $simpletest_path = drupal_get_path('module', 'simpletest'); + $excludePaths = array("$path/coverage_results", "$path/simpletest", "$path/tests", "$path/spikephpcoverage"); + $cov = new CoverageRecorder($includePaths, $excludePaths, $coverage_reporter); + + $cov->startInstrumentation(); + } $test_running = TRUE; $test = simpletest_get_total_test($testlist); switch ($reporter) { @@ -238,6 +257,12 @@ $results = $test->run($reporter); $test_running = FALSE; + if ($coverage) { + $cov->stopInstrumentation(); + $cov->generateReport(); + $coverage_reporter->printTextSummary(); + } + switch (get_class($reporter)) { case 'TextReporter': case 'XMLReporter':