Skip to content

Commit

Permalink
test: fix tap escaping with and without --test
Browse files Browse the repository at this point in the history
PR-URL: #46311
Backport-PR-URL: #46839
Fixes: #45836
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
  • Loading branch information
pulkit-30 authored and juanarbol committed Mar 5, 2023
1 parent 63563f8 commit 32b020c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
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

0 comments on commit 32b020c

Please sign in to comment.