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: fix tap escaping with and without --test #46311

Merged
merged 1 commit into from
Jan 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/internal/test_runner/reporter/tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ function indent(nesting) {

// In certain places, # and \ need to be escaped as \# and \\.
function tapEscape(input) {
let result = StringPrototypeReplaceAll(input, '\\', '\\\\');
result = StringPrototypeReplaceAll(result, '#', '\\#');
result = StringPrototypeReplaceAll(result, '\b', '\\b');
let result = StringPrototypeReplaceAll(input, '\b', '\\b');
result = StringPrototypeReplaceAll(result, '\f', '\\f');
result = StringPrototypeReplaceAll(result, '\t', '\\t');
result = StringPrototypeReplaceAll(result, '\n', '\\n');
result = StringPrototypeReplaceAll(result, '\r', '\\r');
result = StringPrototypeReplaceAll(result, '\v', '\\v');
result = StringPrototypeReplaceAll(result, '\\', '\\\\');
result = StringPrototypeReplaceAll(result, '#', '\\#');
return result;
}

Expand Down
4 changes: 2 additions & 2 deletions test/message/test_runner_output.out
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,8 @@ ok 36 - functionAndOptions # SKIP
---
duration_ms: *
...
# Subtest: escaped description \\ \# \\\#\\ \n \t \f \v \b \r
ok 37 - escaped description \\ \# \\\#\\ \n \t \f \v \b \r
# Subtest: escaped description \\ \# \\\#\\ \\n \\t \\f \\v \\b \\r
ok 37 - escaped description \\ \# \\\#\\ \\n \\t \\f \\v \\b \\r
---
duration_ms: *
...
Expand Down
8 changes: 4 additions & 4 deletions test/message/test_runner_output_cli.out
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ TAP version 13
failureType: 'testCodeFailure'
error: |-
Expected values to be strictly equal:

true !== false

code: 'ERR_ASSERTION'
expected: false
actual: true
Expand Down Expand Up @@ -345,8 +345,8 @@ TAP version 13
---
duration_ms: *
...
# Subtest: escaped description \\ \# \\\#\\ n \\t f \\v b \\r
ok 37 - escaped description \\ \# \\\#\\ n \\t f \\v b \\r
# Subtest: escaped description \\ \# \\\#\\ \\n \\t \\f \\v \\b \\r
ok 37 - escaped description \\ \# \\\#\\ \\n \\t \\f \\v \\b \\r
---
duration_ms: *
...
Expand Down