Uh oh!
There was an error while loading. Please reload this page.
test: fix invalid output TAP if there newline in test name - #45742
Conversation
Hey @aduh95 |
aduh95
commented
Dec 7, 2022
|
| 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.
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
tapEscapeexport that this PR adds tolib/internal/test_runner/tap_stream.js. - Add a test to
test/message/test_runner_output.jsthat uses\n,\r, etc (#and\are already tested IIRC). - Update
test/message/test_runner_output.outto reflect the changes in the test output.
| return StringPrototypeReplaceAll( | ||
| StringPrototypeReplaceAll(input, '\\', '\\\\'), '#', '\\#' | ||
| ); | ||
| [{ escapeChar: '\\', tappedEscape: '\\\\' }, |
There was a problem hiding this comment.
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.
@cjihrig like this... right?
returnStringPrototypeReplaceAll(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.
You could do it that way. You could also do something like this to maintain more readability:
letresult=StringPrototypeReplaceAll(...);result=StringPrototypeReplaceAll(...);result=StringPrototypeReplaceAll(...);returnresult;| ); | ||
| let result = StringPrototypeReplaceAll(input, '\\', '\\\\'); | ||
| result = StringPrototypeReplaceAll(result, '#', '\\#'); | ||
| result = StringPrototypeReplaceAll(result,'\b', '\\b'); |
There was a problem hiding this comment.
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.
Sorry, didn't notice that 😞
fixed 🚀
nodejs-github-bot
commented
Dec 10, 2022
nodejs-github-bot
commented
Dec 11, 2022
Landed in 22dc987 |
PR-URL: nodejs/node#45742Fixes: nodejs/node#45396 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> (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