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: nodejs/node#46311
Fixes: nodejs/node#45836
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
(cherry picked from commit 2f38c74e263ed2e7f3b087efb9adee2442dd25c4)
  • Loading branch information
pulkit-30 authored and MoLow committed Feb 7, 2023
1 parent 3b42f3d commit dfca2fd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions lib/internal/test_runner/reporter/tap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// https://github.com/nodejs/node/blob/a1b27b25bb01aadd3fd2714e4b136db11b7eb85a/lib/internal/test_runner/tap_stream.js
// https://github.com/nodejs/node/blob/2f38c74e263ed2e7f3b087efb9adee2442dd25c4/lib/internal/test_runner/tap_stream.js

'use strict'

Expand Down 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 dfca2fd

Please sign in to comment.