From dfca2fdebca9f134f1dc56e84e5c00011d1d7533 Mon Sep 17 00:00:00 2001 From: Pulkit Gupta Date: Sun, 29 Jan 2023 02:37:47 +0530 Subject: [PATCH] test: fix tap escaping with and without --test PR-URL: https://github.com/nodejs/node/pull/46311 Fixes: https://github.com/nodejs/node/issues/45836 Reviewed-By: Moshe Atlow Reviewed-By: Benjamin Gruenbaum (cherry picked from commit 2f38c74e263ed2e7f3b087efb9adee2442dd25c4) --- lib/internal/test_runner/reporter/tap.js | 8 ++++---- test/message/test_runner_output.out | 4 ++-- test/message/test_runner_output_cli.out | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/internal/test_runner/reporter/tap.js b/lib/internal/test_runner/reporter/tap.js index 30993fc..8ff91fa 100644 --- a/lib/internal/test_runner/reporter/tap.js +++ b/lib/internal/test_runner/reporter/tap.js @@ -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' @@ -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 } diff --git a/test/message/test_runner_output.out b/test/message/test_runner_output.out index 42eae97..15d2009 100644 --- a/test/message/test_runner_output.out +++ b/test/message/test_runner_output.out @@ -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: * ... diff --git a/test/message/test_runner_output_cli.out b/test/message/test_runner_output_cli.out index f2acdd9..3846a23 100644 --- a/test/message/test_runner_output_cli.out +++ b/test/message/test_runner_output_cli.out @@ -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 @@ -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: * ...