Skip to content

test_runner: skip branches entirely on ignored lines#61845

Open
drtootsie wants to merge 1 commit intonodejs:mainfrom
drtootsie:fix-coverage-ignore-branches
Open

test_runner: skip branches entirely on ignored lines#61845
drtootsie wants to merge 1 commit intonodejs:mainfrom
drtootsie:fix-coverage-ignore-branches

Conversation

@drtootsie
Copy link

Fixes: #61586

Summary

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.

Changes

Modified the branch coverage logic in lib/internal/test_runner/coverage.js to check if all lines in the branch are ignored before:

  • Adding to branchReports array
  • Incrementing totalBranches counter

This ensures ignored branches don't pollute coverage reports.

Testing

Requires building Node.js and running the test suite:

./configure && make -j4
make test-only

Fixes: nodejs#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.
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels Feb 15, 2026
range.ignoredLines === range.lines.length) {
branchesCovered++;
// Skip branches that are entirely on ignored lines
if (range.ignoredLines !== range.lines.length) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please cover these changes with tests?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test_runner: node:coverage ignore comments exclude DA but leave BRDA in lcov output

3 participants