Skip to content

Commit 6048b00

Browse files
committed
test_runner: fix lcov BRDA output for ignored branches
Fix BRDA entries appearing in lcov output for branches on lines excluded by /* node:coverage ignore next */ comments. Branches with all ignored lines are now excluded from branchReports (matching DA line exclusion behavior). Ignored branches still count toward coverage statistics but don't appear in detailed reports. Fixes: #61586 Signed-off-by: jorge guerrero <grrr.jrg@gmail.com>
1 parent 5babc8d commit 6048b00

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

lib/internal/test_runner/coverage.js

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -193,18 +193,24 @@ 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) {
196+
// Only add branch to reports if not all lines are ignored
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++;
209+
} else {
210+
// All lines are ignored - count as covered but don't report
204211
branchesCovered++;
212+
totalBranches++;
205213
}
206-
207-
totalBranches++;
208214
}
209215
}
210216

0 commit comments

Comments
 (0)