Skip to content

Commit

Permalink
Updating code coverage tools to use raw data which includes dead and …
Browse files Browse the repository at this point in the history
…uncovered line data.
  • Loading branch information
markstory committed May 9, 2010
1 parent 9a20a23 commit 75d7146
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions cake/tests/lib/coverage/html_coverage_report.php
Expand Up @@ -120,7 +120,7 @@ public function getPathFilter() {
public function filterCoverageDataByPath($path) {
$files = array();
foreach ($this->_rawCoverage as $testRun) {
foreach ($testRun['files'] as $filename => $fileCoverage) {
foreach ($testRun['data'] as $filename => $fileCoverage) {
if (strpos($filename, $path) !== 0) {
continue;
}
Expand All @@ -136,6 +136,7 @@ public function filterCoverageDataByPath($path) {
}
}
}
ksort($files);
return $files;
}

Expand Down Expand Up @@ -214,7 +215,7 @@ function generateDiff($filename, $fileLines, $coverageData) {
$diff[] = $this->_paintLine($line, $lineno, $class);
}

$percentCovered = round($covered / $total, 2);
$percentCovered = round(100 * $covered / $total, 2);

$output .= $this->coverageHeader($filename, $percentCovered);
$output .= implode("", $diff);
Expand Down Expand Up @@ -243,6 +244,7 @@ protected function _paintLine($line, $linenumber, $class) {
* @return void
*/
public function coverageHeader($filename, $percent) {
$filename = basename($filename);
return <<<HTML
<h2>$filename Code coverage: $percent%</h2>
<div class="code-coverage-results">
Expand Down
2 changes: 1 addition & 1 deletion cake/tests/lib/reporter/cake_html_reporter.php
Expand Up @@ -176,7 +176,7 @@ public function paintFooter($result) {
echo $this->_paintLinks();
echo '</div>';
if (isset($this->params['codeCoverage']) && $this->params['codeCoverage']) {
$coverage = $result->getCodeCoverageInformation();
$coverage = $result->getRawCodeCoverageInformation();
echo $this->paintCoverage($coverage);
}
$this->paintDocumentEnd();
Expand Down
2 changes: 1 addition & 1 deletion cake/tests/lib/test_manager.php
Expand Up @@ -162,7 +162,7 @@ public function runGroupTest($groupTestName, $reporter, $codeCoverage = false) {
*/
protected function run($reporter, $codeCoverage = false) {
$result = new PHPUnit_Framework_TestResult;
$result->collectCodeCoverageInformation($codeCoverage);
$result->collectRawCodeCoverageInformation($codeCoverage);
$result->addListener($reporter);
$reporter->paintHeader();
$this->getTestSuite()->run($result);
Expand Down

0 comments on commit 75d7146

Please sign in to comment.