Skip to content
Permalink
Browse files

Enabling code coverage to run on 'All tests' group.

  • Loading branch information...
renan committed Jan 26, 2010
1 parent 81414b7 commit a318ba43fd8dbe6b3c0927b9cb0a9f9cf3058fbf
Showing with 41 additions and 41 deletions.
  1. +3 −3 cake/tests/lib/cake_test_suite_dispatcher.php
  2. +38 −38 cake/tests/lib/code_coverage_manager.php
@@ -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);
}
}
@@ -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;
}

0 comments on commit a318ba4

Please sign in to comment.
You can’t perform that action at this time.