test_runner: fix branch count when ignore comment present#63445
Open
MD-Mushfiqur123 wants to merge 2 commits into
Open
test_runner: fix branch count when ignore comment present#63445MD-Mushfiqur123 wants to merge 2 commits into
MD-Mushfiqur123 wants to merge 2 commits into
Conversation
Collaborator
|
Review requested:
|
Member
|
@MD-Mushfiqur123 there seem to be multiple other PRs open fixing this bug, this seems like a duplicate? |
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.
Fixes: #61586
When /* node:coverage ignore next */\ is used on a line within a branch (e.g., a
eturn\ after an \if), the DA line entry is correctly excluded from the coverage output. However, the BRDA branch entry still showed \count=0\ for the branch leading to the ignored code.
The existing condition
ange.ignoredLines === range.lines.length\ only caught the case where ALL lines in a V8 range are ignored. But V8 branch ranges often include non-executable lines (like closing braces and comment lines) alongside the ignored executable line, so the strict equality check missed many cases.
Changes in \lib/internal/test_runner/coverage.js:
ange.count === 0\ and
ange.ignoredLines > 0, set the branch count to 1 (covered) in the branch report
ange.ignoredLines === range.lines.length\ to
ange.ignoredLines > 0\
This matches c8's behavior, which marks both DA and BRDA as covered for ignored lines.