Skip to content

test_runner: compute source-mapped line counts after merge - #68018

Open
prateeknitcse wants to merge 1 commit into
nodejs:mainfrom
prateeknitcse:fix-source-map-coverage-order
Open

prateeknitcse wants to merge 1 commit into
nodejs:mainfrom
prateeknitcse:fix-source-map-coverage-order

Conversation

@prateeknitcse

Copy link
Copy Markdown
Contributor

Fixes: #67077

mapCoverageWithSourceMap() was mutating line counts in the shared #sourceLines map while reading each individual coverage file, before mergeCoverage() finished combining them. Because mapRangeToLines() in summary() skips lines that a range only covers partially (like export function add), whichever coverage file happened to be read last decided the count for that line.

This removes the early per-file write in mapCoverageWithSourceMap(), tracks source-mapped URLs on TestCoverage, and updates partial-line counts in mapRangeToLines() from the merged ranges during summary().

I reproduced the issue locally and verified the updated coverage.js logic directly against captured V8 coverage payloads in both merge orders, plus ESLint on the two touched files. Relying on CI for the full binary test run since I haven't completed a local build of main.

mapCoverageWithSourceMap() used to update line counts in the shared
#sourceLines map while reading each process coverage file. When a
source-mapped range started mid-line (such as after `export `),
mapRangeToLines() later skipped that line in summary(), leaving
whichever coverage file happened to be read last to set the count.

Move source-mapped line count updates into summary() via
mapRangeToLines() so counts are always derived from the merged ranges.

Fixes: nodejs#67077
Signed-off-by: prateeksingh <prateeksingh010101@gmail.com>
@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 Dec 4, 2026
@github-actions

github-actions Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Caution

AgentScan found account activity patterns that may be consistent with automation. This is a heuristic, not proof that this pull request was opened by an agent or violates policy. AI-assisted contributions are permitted, but automated tooling must not open pull requests without advance approval, and contributors must personally understand, test, verify, and take responsibility for every submitted change. See the AgentScan analysis, AI use policy, and automation policy for additional context.

@codecov

codecov Bot commented Dec 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.63%. Comparing base (62ebcbe) to head (7291ee8).
⚠️ Report is 31 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #68018      +/-   ##
==========================================
+ Coverage   90.58%   90.63%   +0.05%     
==========================================
  Files         802      802              
  Lines      286915   287052     +137     
  Branches    55404    55486      +82     
==========================================
+ Hits       259902   260180     +278     
+ Misses      17100    16948     -152     
- Partials     9913     9924      +11     
Files with missing lines Coverage Δ
lib/internal/test_runner/coverage.js 81.47% <100.00%> (+21.66%) ⬆️

... and 40 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

Labels

agentscan:automated-account 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: source-mapped line coverage varies between identical runs

2 participants