-
Notifications
You must be signed in to change notification settings - Fork 30.5k
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
Changes from 3 commits
6ea386e
7ac8cba
b3bc57f
e4ea715
5b8e01e
6a6f57e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe 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:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. updating this 👍🏽 🚀 |
||
|
||
const cases = [ | ||
{ | ||
|
@@ -627,3 +628,17 @@ ok 1 - test 1 | |
expected.map((item) => ({ __proto__: null, ...item })) | ||
); | ||
})().then(common.mustCall()); | ||
|
||
(async () => { | ||
[{ escapeChar: '\\', tappedEscape: '\\\\' }, | ||
{ escapeChar: '#', tappedEscape: '\\#' }, | ||
{ escapeChar: '\n', tappedEscape: '\\n' }, | ||
{ escapeChar: '\t', tappedEscape: '\\t' }, | ||
{ escapeChar: '\r', tappedEscape: '\\r' }, | ||
{ escapeChar: '\f', tappedEscape: '\\f' }, | ||
{ escapeChar: '\b', tappedEscape: '\\b' }, | ||
{ escapeChar: '\v', tappedEscape: '\\v' }, | ||
].forEach(({ escapeChar, tappedEscape }) => { | ||
assert.strictEqual(tapEscape(escapeChar), tappedEscape); | ||
}); | ||
})().then(common.mustCall()); |
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?
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:
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