Skip to content
Permalink
Browse files

Updating code coverage tools to use raw data which includes dead and …

…uncovered line data.
  • Loading branch information...
markstory committed May 9, 2010
1 parent 9a20a23 commit 75d7146bd0323bee80f488d05e6b7d346ac64aa7
@@ -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;
}
@@ -136,6 +136,7 @@ public function filterCoverageDataByPath($path) {
}
}
}
ksort($files);
return $files;
}
@@ -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);
@@ -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">
@@ -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();
@@ -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);

0 comments on commit 75d7146

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