Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14674266
D15343.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D15343.diff
View Options
diff --git a/src/unit/parser/ArcanistPhpunitTestResultParser.php b/src/unit/parser/ArcanistPhpunitTestResultParser.php
--- a/src/unit/parser/ArcanistPhpunitTestResultParser.php
+++ b/src/unit/parser/ArcanistPhpunitTestResultParser.php
@@ -129,34 +129,33 @@
$line_count = count(file($class_path));
$coverage = '';
+ $any_line_covered = false;
$start_line = 1;
$lines = $file->getElementsByTagName('line');
- for ($ii = 0; $ii < $lines->length; $ii++) {
- $line = $lines->item($ii);
- for (; $start_line < $line->getAttribute('num'); $start_line++) {
- $coverage .= 'N';
- }
+ $coverage = str_repeat('N', $line_count);
+ foreach ($lines as $line) {
if ($line->getAttribute('type') != 'stmt') {
- $coverage .= 'N';
+ continue;
+ }
+ if ((int)$line->getAttribute('count') > 0) {
+ $is_covered = 'C';
+ $any_line_covered = true;
} else {
- if ((int)$line->getAttribute('count') == 0) {
- $coverage .= 'U';
- } else if ((int)$line->getAttribute('count') > 0) {
- $coverage .= 'C';
- }
+ $is_covered = 'U';
}
-
- $start_line++;
+ $line_no = (int)$line->getAttribute('num');
+ $coverage[$line_no - 1] = $is_covered;
}
- for (; $start_line <= $line_count; $start_line++) {
- $coverage .= 'N';
+ // Sometimes the Clover coverage gives false positives on uncovered lines
+ // when the file wasn't actually part of the test. This filters out files
+ // with no coverage which helps give more accurate overall results.
+ if ($any_line_covered) {
+ $len = strlen($this->projectRoot.DIRECTORY_SEPARATOR);
+ $class_path = substr($class_path, $len);
+ $reports[$class_path] = $coverage;
}
-
- $len = strlen($this->projectRoot.DIRECTORY_SEPARATOR);
- $class_path = substr($class_path, $len);
- $reports[$class_path] = $coverage;
}
return $reports;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Jan 13, 5:52 PM (15 h, 44 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6990093
Default Alt Text
D15343.diff (2 KB)
Attached To
Mode
D15343: Filter out some Clover coverage to prevent false positives
Attached
Detach File
Event Timeline
Log In to Comment