Skip to content

Commit 06c7fa2

Browse files
committed
test_runner: skip branches entirely on ignored lines
Fixes: #61586 When a branch is entirely on ignored lines (via c8 ignore comments), it should not appear in the BRDA output at all, rather than appearing with 0 coverage. Modified the branch coverage logic to check if all lines in the branch are ignored before adding to branchReports and incrementing totalBranches. This ensures ignored branches don't pollute coverage reports.
1 parent a57893b commit 06c7fa2

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

lib/internal/test_runner/coverage.js

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -193,18 +193,20 @@ class TestCoverage {
193193
ObjectAssign(range, mapRangeToLines(range, lines));
194194

195195
if (isBlockCoverage) {
196-
ArrayPrototypePush(branchReports, {
197-
__proto__: null,
198-
line: range.lines[0]?.line,
199-
count: range.count,
200-
});
201-
202-
if (range.count !== 0 ||
203-
range.ignoredLines === range.lines.length) {
204-
branchesCovered++;
196+
// Skip branches that are entirely on ignored lines
197+
if (range.ignoredLines !== range.lines.length) {
198+
ArrayPrototypePush(branchReports, {
199+
__proto__: null,
200+
line: range.lines[0]?.line,
201+
count: range.count,
202+
});
203+
204+
if (range.count !== 0) {
205+
branchesCovered++;
206+
}
207+
208+
totalBranches++;
205209
}
206-
207-
totalBranches++;
208210
}
209211
}
210212

0 commit comments

Comments
 (0)