Skip to content

test_runner: mark ignored lcov branches covered#63371

Open
Sean-Kenneth-Doherty wants to merge 1 commit into
nodejs:mainfrom
Sean-Kenneth-Doherty:codex/coverage-ignore-lcov-branches
Open

test_runner: mark ignored lcov branches covered#63371
Sean-Kenneth-Doherty wants to merge 1 commit into
nodejs:mainfrom
Sean-Kenneth-Doherty:codex/coverage-ignore-lcov-branches

Conversation

@Sean-Kenneth-Doherty
Copy link
Copy Markdown

Fixes #61586.

When a node:coverage ignore next directive covers an unexecuted branch body, the line entry is omitted from LCOV but the branch entry is still emitted as uncovered. This makes LCOV branch totals fail even though the branch points only at ignored source.

This change detects zero-count branch ranges whose only uncovered source is ignored or non-executable scaffolding, then reports that branch as covered. The LCOV output keeps BRF stable while moving BRH and the matching BRDA entry to covered, matching the ignore behavior expected by the issue and by c8-style output.

A focused regression fixture covers a truthy-only branch with an ignored falsy return and asserts the LCOV report has no zero-count BRDA, reports BRF:3 / BRH:3, and still omits the ignored return from DA.

Checks run locally:

  • node --check lib/internal/test_runner/coverage.js
  • node --test --test-name-pattern "lcov reporter excludes ignored branch ranges" test/parallel/test-runner-coverage.js (fails against the installed system Node before this patch, showing the stale BRDA:...,0 / BRH:2 behavior)
  • tools/eslint/node_modules/eslint/bin/eslint.js --cache --max-warnings=0 --report-unused-disable-directives --no-warn-ignored lib/internal/test_runner/coverage.js test/parallel/test-runner-coverage.js test/fixtures/test-runner/coverage-ignored-branch.js test/fixtures/test-runner/coverage-ignored-branch.test.js
  • git diff --cached --check

I attempted a local built-binary verification as well, but this environment could not complete a Node build before hitting temporary-space/toolchain constraints; CI should exercise the patched binary path.

@nodejs-github-bot
Copy link
Copy Markdown
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 May 16, 2026
@Sean-Kenneth-Doherty Sean-Kenneth-Doherty marked this pull request as ready for review May 17, 2026 06:04
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

2 participants