-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: fix invalid output TAP if there newline in test name #45742
Conversation
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.
This needs a test.
StringPrototypeReplaceAll(input, '\\', '\\\\'), '#', '\\#' | ||
); | ||
), '\n', '\\n'); |
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.
What about \r
, \v
, \b
, and \f
?
Hey @aduh95 |
|
@@ -4,6 +4,7 @@ const common = require('../common'); | |||
const assert = require('node:assert'); | |||
const { TapParser } = require('internal/test_runner/tap_parser'); | |||
const { TapChecker } = require('internal/test_runner/tap_checker'); | |||
const { tapEscape } = require('internal/test_runner/tap_stream'); |
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.
So, I don't think this file is the best place for testing this. This file is more about the TAP parser.
I would test this by doing the following:
- Undo the changes in this file.
- Remove the
tapEscape
export that this PR adds tolib/internal/test_runner/tap_stream.js
. - Add a test to
test/message/test_runner_output.js
that uses\n
,\r
, etc (#
and\
are already tested IIRC). - Update
test/message/test_runner_output.out
to reflect the changes in the test output.
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.
updating this 👍🏽 🚀
return StringPrototypeReplaceAll( | ||
StringPrototypeReplaceAll(input, '\\', '\\\\'), '#', '\\#' | ||
); | ||
[{ escapeChar: '\\', tappedEscape: '\\\\' }, |
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.
Even though the resulting code will not look as nice as this, I'm inclined to use a series of StringPrototypeReplaceAll()
calls here instead.
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.
@cjihrig like this... right?
return StringPrototypeReplaceAll(StringPrototypeReplaceAll(
StringPrototypeReplaceAll(StringPrototypeReplaceAll(
StringPrototypeReplaceAll(StringPrototypeReplaceAll(
StringPrototypeReplaceAll(StringPrototypeReplaceAll(input, '\\', '\\\\'), '#', '\\#'),
'\b', '\\b'), '\f', '\\f'), '\t', '\\t'), '\n', '\\n'), '\r', '\\r'), '\v', '\\v');
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.
You could do it that way. You could also do something like this to maintain more readability:
let result = StringPrototypeReplaceAll(...);
result = StringPrototypeReplaceAll(...);
result = StringPrototypeReplaceAll(...);
return result;
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.
Got it 👍🏽
Thanks
); | ||
let result = StringPrototypeReplaceAll(input, '\\', '\\\\'); | ||
result = StringPrototypeReplaceAll(result, '#', '\\#'); | ||
result = StringPrototypeReplaceAll(result,'\b', '\\b'); |
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.
Same change on the following lines. Other than that, I think this looks good.
result = StringPrototypeReplaceAll(result,'\b', '\\b'); | |
result = StringPrototypeReplaceAll(result, '\b', '\\b'); |
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.
Sorry, didn't notice that 😞
fixed 🚀
Landed in 22dc987 |
PR-URL: nodejs#45742 Fixes: nodejs#45396 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #45742 Fixes: #45396 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #45742 Fixes: #45396 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #45742 Fixes: #45396 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #45742 Fixes: #45396 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #45742 Fixes: #45396 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #45742 Fixes: #45396 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #45742 Fixes: #45396 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: nodejs/node#45742 Fixes: nodejs/node#45396 Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> (cherry picked from commit 22dc987fde29734c5bcbb7c33da20d184ff61627)
fixes: #45396
fix test outputs invalid TAP if there is a newline in the test name
Fixed Changes
Test Case:
Output