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
Fixes: #45836
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
  • Loading branch information
pulkit-30 authored and ruyadorno committed Jan 31, 2023
1 parent 367dc41 commit 8a45c9d
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 @@ -94,14 +94,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 8a45c9d

Please sign in to comment.