Skip to content

Commit

Permalink
Enabling code coverage to run on 'All tests' group.
Browse files Browse the repository at this point in the history
  • Loading branch information
renan committed Jan 26, 2010
1 parent 81414b7 commit a318ba4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 41 deletions.
6 changes: 3 additions & 3 deletions cake/tests/lib/cake_test_suite_dispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,12 @@ function _parseParams() {
*/
function _runGroupTest() {
$Reporter =& CakeTestSuiteDispatcher::getReporter();
if ($this->params['codeCoverage']) {
CodeCoverageManager::init($this->params['group'], $Reporter);
}
if ('all' == $this->params['group']) {
$this->Manager->runAllTests($Reporter);
} else {
if ($this->params['codeCoverage']) {
CodeCoverageManager::init($this->params['group'], $Reporter);
}
$this->Manager->runGroupTest(ucfirst($this->params['group']), $Reporter);
}
}
Expand Down
76 changes: 38 additions & 38 deletions cake/tests/lib/code_coverage_manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -530,50 +530,50 @@ function __testObjectFilesFromGroupFile($groupFile, $isApp = true) {
$manager = CodeCoverageManager::getInstance();
$testManager =& new TestManager();

$path = TESTS . 'groups';

$path = TESTS;
if (!$isApp) {
$path = ROOT . DS . 'cake' . DS . 'tests' . DS . 'groups';
$path = ROOT . DS . 'cake' . DS . 'tests';
}

if (!!$manager->pluginTest) {
$path = APP . 'plugins' . DS . $manager->pluginTest . DS . 'tests' . DS . 'groups';

$pluginPaths = App::path('plugins');
foreach ($pluginPaths as $pluginPath) {
$tmpPath = $pluginPath . $manager->pluginTest . DS . 'tests' . DS. 'groups';
if (file_exists($tmpPath)) {
$path = $tmpPath;
break;
}
}
}
$path .= DS . $groupFile . $testManager->_groupExtension;

if (!file_exists($path)) {
trigger_error(__('This group file does not exist!', true));
return array();
$path = App::pluginPath($manager->pluginTest) . DS . 'tests';
}

$result = array();
$groupContent = file_get_contents($path);
$ds = '\s*\.\s*DS\s*\.\s*';
$pluginTest = 'APP\.\'plugins\'' . $ds . '\'' . $manager->pluginTest . '\'' . $ds . '\'tests\'' . $ds . '\'cases\'';
$pluginTest .= '|App::pluginPath\(\'' . $manager->pluginTest . '\'\)' . $ds . '\'tests\'' . $ds . '\'cases\'';
$pattern = '/\s*TestManager::addTestFile\(\s*\$this,\s*(' . $pluginTest . '|APP_TEST_CASES|CORE_TEST_CASES)' . $ds . '(.*?)\)/i';
preg_match_all($pattern, $groupContent, $matches);

foreach ($matches[2] as $file) {
$patterns = array(
'/\s*\.\s*DS\s*\.\s*/',
'/\s*APP_TEST_CASES\s*/',
'/\s*CORE_TEST_CASES\s*/',
);

$replacements = array(DS, '', '');
$file = preg_replace($patterns, $replacements, $file);
$file = str_replace("'", '', $file);
$result[] = $manager->__testObjectFileFromCaseFile($file, $isApp) . '.php';
if ($groupFile == 'all') {
$files = array_keys($testManager->getTestCaseList());
foreach ($files as $file) {
$file = str_replace(DS . 'tests' . DS . 'cases' . DS, DS, $file);
$file = str_replace('.test.php', '.php', $file);
$file = str_replace(DS . DS, DS, $file);
$result[] = $file;
}
} else {
$path .= DS . 'groups' . DS . $groupFile . $testManager->_groupExtension;
if (!file_exists($path)) {
trigger_error(__('This group file does not exist!', true));
return array();
}

$result = array();
$groupContent = file_get_contents($path);
$ds = '\s*\.\s*DS\s*\.\s*';
$pluginTest = 'APP\.\'plugins\'' . $ds . '\'' . $manager->pluginTest . '\'' . $ds . '\'tests\'' . $ds . '\'cases\'';
$pluginTest .= '|App::pluginPath\(\'' . $manager->pluginTest . '\'\)' . $ds . '\'tests\'' . $ds . '\'cases\'';
$pattern = '/\s*TestManager::addTestFile\(\s*\$this,\s*(' . $pluginTest . '|APP_TEST_CASES|CORE_TEST_CASES)' . $ds . '(.*?)\)/i';
preg_match_all($pattern, $groupContent, $matches);

foreach ($matches[2] as $file) {
$patterns = array(
'/\s*\.\s*DS\s*\.\s*/',
'/\s*APP_TEST_CASES\s*/',
'/\s*CORE_TEST_CASES\s*/',
);

$replacements = array(DS, '', '');
$file = preg_replace($patterns, $replacements, $file);
$file = str_replace("'", '', $file);
$result[] = $manager->__testObjectFileFromCaseFile($file, $isApp) . '.php';
}
}
return $result;
}
Expand Down

0 comments on commit a318ba4

Please sign in to comment.