Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.4k
test_runner: allow special characters in snapshot keys#57017
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: allow special characters in snapshot keys #57017
Uh oh!
There was an error while loading. Please reload this page.
Conversation
nodejs-github-bot commented Feb 12, 2025
Review requested:
|
Ceres6 commented Feb 12, 2025
codecovbot commented Feb 12, 2025 • edited
Loading Uh oh!
There was an error while loading. Please reload this page.
edited
Uh oh!
There was an error while loading. Please reload this page.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@## main #57017 +/- ## ========================================== - Coverage 89.15% 89.07% -0.09% ========================================== Files 665 665 Lines 192798 193312 +514 Branches 37130 37263 +133 ========================================== + Hits 171886 172187 +301 - Misses 13673 13829 +156 - Partials 7239 7296 +57
|
Uh oh!
There was an error while loading. Please reload this page.
lib/internal/test_runner/snapshot.js Outdated
| setSnapshot(id,value){ | ||
| this.snapshots[templateEscape(id)]=value; | ||
| this.snapshots[keyEscape(id)]=value; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this appears to duplicate much of templateEscape(), couldn't we do this instead: keyEscape(templateEscape(id))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it but then it starts failing as we over-escape things, the problem is with the \\ to \\\\ replace
| file.setSnapshot('\r 1','test'); | ||
| t.assert.strictEqual(file.getSnapshot('\\r 1'),'test'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the bug happens while reading the snapshots back. I think for this case, it would be better to test a full round trip (write the file and then read it back) using the public APIs. It would probably be good to check a couple more cases besides just \r since in #56836 (comment), it was reported that this happens for a range of inputs (not saying we should test every single input though).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test was failing before the check, but I will add an e2e test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAICS the range in that comment is the block of high surrogate and low surrogate pairs which are reserved for utf-16 and shouldn't appear, but I'm not an expert on this, so not sure
targos commented Feb 14, 2025
There's a typo in the commit message: especial -> special |
aduh95 commented Feb 15, 2025
Also, the subsystem should be |
b91c14b to 06b3b94CompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
db614e3 to 02bbd1dCompare
pmarchini left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This comment was marked as outdated.
This comment was marked as outdated.
nodejs-github-bot commented Feb 18, 2025
baa60ce into nodejs:mainUh oh!
There was an error while loading. Please reload this page.
nodejs-github-bot commented Feb 19, 2025
Landed in baa60ce |
Fixes: nodejs#56836 PR-URL: nodejs#57017 Reviewed-By: Pietro Marchini <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
Fixes: #56836 PR-URL: #57017 Reviewed-By: Pietro Marchini <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
Fixes: #56836 PR-URL: #57017 Reviewed-By: Pietro Marchini <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
Fixes: #56836 PR-URL: #57017 Reviewed-By: Pietro Marchini <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
Fixes: #56836 PR-URL: #57017 Reviewed-By: Pietro Marchini <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
Fixes: #56836 PR-URL: #57017 Reviewed-By: Pietro Marchini <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
Fixes: #56836 PR-URL: #57017 Reviewed-By: Pietro Marchini <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
Use
JSONStringifyto serialise snapshot keys to allow special characters such as\rto be used in test namesFixes: #56836