test_runner: exclude BRDA entries for ignored lines in LCOV reporter#1
Open
sfgrdsgdsfdrfyg-code wants to merge 1 commit intomainfrom
Open
test_runner: exclude BRDA entries for ignored lines in LCOV reporter#1sfgrdsgdsfdrfyg-code wants to merge 1 commit intomainfrom
sfgrdsgdsfdrfyg-code wants to merge 1 commit intomainfrom
Conversation
0facea0 to
a7f3aed
Compare
When a line is marked with /* node:coverage ignore next */, the DA entry for that line is correctly excluded from the LCOV output. However, the corresponding BRDA entry was still being emitted, causing branch coverage to report incorrect percentages when using the lcov reporter. This commit adds: - A new test fixture (brda_ignore_output.js) with a branch that has /* node:coverage ignore next */ to test the BRDA exclusion behavior - A new test runner (lcov_reporter_brda_ignore.js) for the fixture - A separate snapshot test case for this specific scenario - Updates to lcov.js to filter BRDA entries for ignored lines PR-URL: nodejs#62740
a7f3aed to
9dbb702
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a line is marked with
/* node:coverage ignore next */, the DA (line coverage) entry for that line is correctly excluded from the LCOV output. However, the corresponding BRDA (branch coverage) entry was still being emitted, causing branch coverage to report uncovered branches for code that should be ignored.This results in incorrect branch coverage percentages (e.g., 66.67% instead of 100%) and impacts CI/CD pipelines that enforce branch coverage thresholds.
Fix
Build a set of ignored line numbers from
file.lines(which includes theignoreflag) and skip BRDA entries for those lines.Testing
The issue includes a minimal reproduction at https://github.com/tobigumo/node-coverage-brda-bug
Steps to reproduce:
/* node:coverage ignore next */comment on the fallback branchnode --experimental-test-coverage --test-reporter=lcov --test-reporter-destination=coverage/lcov.info --test test/example.test.jsBRDA:4,2,0,0remains in lcov.info (the bug)Comparison with c8
Using
c8with/* c8 ignore next */on the same code structure correctly marks both DA and BRDA as covered for ignored lines. This fix aligns Node.js native coverage with c8 behavior.Closes nodejs#61586