Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_runner: throw on invalid source map #55055

Conversation

RedYetiDev
Copy link
Member

@RedYetiDev RedYetiDev commented Sep 21, 2024

This PR changes the code coverage test runner to throw ERR_SOURCE_MAP_CORRUPT when a sourcemap is not a valid JSON file, or does not exist.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added errors Issues and PRs related to JavaScript errors originated in Node.js core. needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels Sep 21, 2024
Copy link

codecov bot commented Sep 21, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 88.41%. Comparing base (8de2695) to head (87af23b).
Report is 290 commits behind head on main.

Files with missing lines Patch % Lines
lib/internal/test_runner/coverage.js 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #55055      +/-   ##
==========================================
- Coverage   88.41%   88.41%   -0.01%     
==========================================
  Files         652      652              
  Lines      186576   186579       +3     
  Branches    36049    36049              
==========================================
- Hits       164960   164955       -5     
- Misses      14889    14900      +11     
+ Partials     6727     6724       -3     
Files with missing lines Coverage Δ
lib/internal/errors.js 96.98% <100.00%> (+<0.01%) ⬆️
lib/internal/test_runner/coverage.js 64.65% <50.00%> (-0.05%) ⬇️

... and 35 files with indirect coverage changes

@RedYetiDev RedYetiDev force-pushed the test-runner-throw-invalid-source-map branch from 095e3e3 to a916ce4 Compare September 22, 2024 20:57
@RedYetiDev
Copy link
Member Author

RedYetiDev commented Sep 22, 2024

The first commit is #55037, which will land shortly. This PR adds ERR_SOURCE_MAP_CANNOT_PARSE for when the source map does not exist / is not valid JSON

@RedYetiDev RedYetiDev added commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. coverage Issues and PRs related to native coverage support. source maps Issues and PRs related to source map support. labels Sep 22, 2024
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@RedYetiDev RedYetiDev force-pushed the test-runner-throw-invalid-source-map branch from a916ce4 to 51f959c Compare September 23, 2024 20:32
Copy link
Contributor

@cjihrig cjihrig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please stop changing unrelated things in PRs. It makes PRs more difficult to review and is more likely to introduce issues. If you feel strongly that the source map fixtures should be renamed, please do that in a separate PR.

];

describe('Coverage with source maps', async () => {
await it('should work with source maps', async (t) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need the awaits on the tests.

@@ -353,6 +354,7 @@ class TestCoverage {
continue;
}
const { data, lineLengths } = sourceMapCache[url];
if (!data) throw new ERR_SOURCE_MAP_CANNOT_PARSE(url);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit torn on this error for a couple of reasons:

  • The error says that the source map does not exist or cannot be parsed... but there is still an entry for it in the source map cache.
  • The fact that this error is about source maps, but it is only thrown from the test runner even though there is other source map functionality in core.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error says that the source map does not exist or cannot be parsed... but there is still an entry for it in the source map cache.

There is an entry, but it's empty.


Before this change, an error was thrown because the entry was empty, and therefore didn't have any properties. Does that error get thrown anywhere else? If so, I can try and handle them as well

@RedYetiDev
Copy link
Member Author

RedYetiDev commented Sep 24, 2024

Please stop changing unrelated things in PRs. It makes PRs more difficult to review and is more likely to introduce issues. If you feel strongly that the source map fixtures should be renamed, please do that in a separate PR.

IMO it's related because this adds tests, and moving them into their own file is good for decluttering, but I'll move it feel it's unrelated.

@RedYetiDev RedYetiDev force-pushed the test-runner-throw-invalid-source-map branch from 7aad9a2 to 1e8287f Compare September 30, 2024 19:10
@RedYetiDev RedYetiDev added blocked PRs that are blocked by other issues or PRs. and removed commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. labels Sep 30, 2024
@RedYetiDev RedYetiDev force-pushed the test-runner-throw-invalid-source-map branch from 97d87a6 to 87af23b Compare October 3, 2024 23:21
@RedYetiDev RedYetiDev removed the blocked PRs that are blocked by other issues or PRs. label Oct 3, 2024
@cjihrig cjihrig added the request-ci Add this label to start a Jenkins CI on a PR. label Oct 6, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Oct 6, 2024
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@cjihrig cjihrig added commit-queue Add this label to land a pull request using GitHub Actions. and removed needs-ci PRs that need a full CI run. labels Oct 6, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Oct 6, 2024
@nodejs-github-bot nodejs-github-bot merged commit 9a9409f into nodejs:main Oct 6, 2024
59 checks passed
@nodejs-github-bot
Copy link
Collaborator

Landed in 9a9409f

aduh95 pushed a commit that referenced this pull request Oct 9, 2024
PR-URL: #55055
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@aduh95 aduh95 mentioned this pull request Oct 9, 2024
louwers pushed a commit to louwers/node that referenced this pull request Nov 2, 2024
PR-URL: nodejs#55055
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
@marco-ippolito marco-ippolito added the backport-requested-v20.x PRs awaiting manual backport to the v20.x-staging branch. label Nov 16, 2024
tpoisseau pushed a commit to tpoisseau/node that referenced this pull request Nov 21, 2024
PR-URL: nodejs#55055
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-requested-v20.x PRs awaiting manual backport to the v20.x-staging branch. coverage Issues and PRs related to native coverage support. errors Issues and PRs related to JavaScript errors originated in Node.js core. source maps Issues and PRs related to source map support. test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants