test_runner: use source maps when reporting coverage#52060
test_runner: use source maps when reporting coverage#52060nodejs-github-bot merged 2 commits intonodejs:mainfrom
Conversation
|
Review requested:
|
e0d502c to
326f7a0
Compare
326f7a0 to
e9dcde5
Compare
| .findEntry(lines[lines.length - 1].line - 1, (endOffset - lines[lines.length - 1].startOffset) - 1); | ||
| if (!startEntry.originalSource && endEntry.originalSource && | ||
| lines[0].line === 1 && startOffset === 0 && lines[0].startOffset === 0) { | ||
| // Edge case when the first line is not mappable |
There was a problem hiding this comment.
Why is the first line not mappable? It looks like there are a couple more "not mappable" comments. Do you know why they aren't mappable? If so, can it be included in the comments.
There was a problem hiding this comment.
what findEntry does is a binary search for the first entry that appears in the source map after the line/column you request.
there are many cases where such an entry cannot be found (generated code doesn't always point to a source for various reasons - it might be a comment added by the build tool source maps exclude node_modules, etc)
this specific edge case is important since v8 coverage will almost always have a range starting at the beginning of generating code ({line:0,col:0}) until the end of the end of the file. since this range marks the count of for all top-level lines outside of a functions it is very important so I added a specific handling for it
node/lib/internal/source_map/source_map.js
Lines 190 to 220 in 1abff07
Commit Queue failed- Loading data for nodejs/node/pull/52060 ✔ Done loading data for nodejs/node/pull/52060 ----------------------------------- PR info ------------------------------------ Title test_runner: use source maps when reporting coverage (#52060) Author Moshe Atlow (@MoLow) Branch MoLow:test-runner-coverage-use-source-maps -> nodejs:main Labels needs-ci, commit-queue-rebase, test_runner Commits 2 - test_runner: use source maps when reporting coverage - CR Committers 1 - Moshe Atlow PR-URL: https://github.com/nodejs/node/pull/52060 Reviewed-By: Colin Ihrig Reviewed-By: Benjamin Gruenbaum Reviewed-By: Chemi Atlow ------------------------------ Generated metadata ------------------------------ PR-URL: https://github.com/nodejs/node/pull/52060 Reviewed-By: Colin Ihrig Reviewed-By: Benjamin Gruenbaum Reviewed-By: Chemi Atlow -------------------------------------------------------------------------------- ℹ This PR was created on Tue, 12 Mar 2024 19:35:56 GMT ✔ Approvals: 3 ✔ - Colin Ihrig (@cjihrig): https://github.com/nodejs/node/pull/52060#pullrequestreview-1932962596 ✔ - Benjamin Gruenbaum (@benjamingr) (TSC): https://github.com/nodejs/node/pull/52060#pullrequestreview-1935039694 ✔ - Chemi Atlow (@atlowChemi): https://github.com/nodejs/node/pull/52060#pullrequestreview-1935240850 ✔ Last GitHub CI successful ℹ Last Full PR CI on 2024-03-13T22:31:45Z: https://ci.nodejs.org/job/node-test-pull-request/57738/ - Querying data for job/node-test-pull-request/57738/ ✔ Last Jenkins CI successful -------------------------------------------------------------------------------- ✔ No git cherry-pick in progress ✔ No git am in progress ✔ No git rebase in progress -------------------------------------------------------------------------------- - Bringing origin/main up to date... From https://github.com/nodejs/node * branch main -> FETCH_HEAD ✔ origin/main is now up-to-date - Downloading patch for 52060 From https://github.com/nodejs/node * branch refs/pull/52060/merge -> FETCH_HEAD ✔ Fetched commits as b360532f1a38..9902bc5a26e5 -------------------------------------------------------------------------------- [main d74f9351de] test_runner: use source maps when reporting coverage Author: Moshe Atlow Date: Mon Mar 11 22:44:25 2024 +0200 11 files changed, 302 insertions(+), 118 deletions(-) create mode 100644 test/fixtures/test-runner/coverage/README.md create mode 100644 test/fixtures/test-runner/coverage/a.test.mjs create mode 100644 test/fixtures/test-runner/coverage/a.test.mjs.map create mode 100644 test/fixtures/test-runner/coverage/a.test.ts create mode 100644 test/fixtures/test-runner/coverage/b.test.ts create mode 100644 test/fixtures/test-runner/coverage/index.test.js create mode 100644 test/fixtures/test-runner/coverage/stdin.test.js create mode 100644 test/fixtures/test-runner/coverage/stdin.test.js.map [main 0c669f7030] CR Author: Moshe Atlow Date: Wed Mar 13 21:17:38 2024 +0200 3 files changed, 3 insertions(+), 5 deletions(-) ✔ Patches applied There are 2 commits in the PR. Attempting autorebase. Rebasing (2/4)https://github.com/nodejs/node/actions/runs/8286634396 |
|
Landed in 814fa1a |
PR-URL: nodejs#52060 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
|
@MoLow should the source map limitation in the docs be removed after this change? |
PR-URL: #52060 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
PR-URL: #52060 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
PR-URL: nodejs#52060 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
No description provided.