From f7e61e0d11f1825d169903b57bbd8f73628682d9 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Fri, 15 Oct 2010 03:07:08 +0000 Subject: [PATCH] ENHANCEMENT Added TestRunner::$coverage_filter_dirs to exclude certain directories from PHPUnit test coverage reports (from r106877) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112542 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- dev/TestRunner.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/dev/TestRunner.php b/dev/TestRunner.php index 483165cfc..645a7fed5 100644 --- a/dev/TestRunner.php +++ b/dev/TestRunner.php @@ -52,6 +52,21 @@ class TestRunner extends Controller { '$TestCase' => 'only', ); + /** + * @var Array Blacklist certain directories for the coverage report. + * Filepaths are relative to the webroot, without leading slash. + * + * @see http://www.phpunit.de/manual/current/en/appendixes.configuration.html#appendixes.configuration.blacklist-whitelist + */ + static $coverage_filter_dirs = array( + 'cms/thirdparty', + 'cms/tests', + 'cms/lang', + 'sapphire/thirdparty', + 'sapphire/tests', + 'sapphire/lang', + ); + /** * Override the default reporter with a custom configured subclass. * @@ -264,6 +279,10 @@ class TestRunner extends Controller { $results->addListener($reporter); if($coverage === true) { + foreach(self::$coverage_filter_dirs as $dir) { + PHPUnit_Util_Filter::addDirectoryToFilter(BASE_PATH . '/' . $dir); + } + $results->collectCodeCoverageInformation(true); $suite->run($results);