From 2c0ec1d96b6b5ef0ce9cff8ecbaf34afbe39e811 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 --- lib/internal/test_runner/reporter/tap.js | 6 +++--- test/message/test_runner_output.out | 4 ++-- test/message/test_runner_output_cli.out | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/lib/internal/test_runner/reporter/tap.js b/lib/internal/test_runner/reporter/tap.js index ebf7be80e2a2f5..20514a88e1741a 100644 --- a/lib/internal/test_runner/reporter/tap.js +++ b/lib/internal/test_runner/reporter/tap.js @@ -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; } diff --git a/test/message/test_runner_output.out b/test/message/test_runner_output.out index 42eae979daf6dd..15d2009816a961 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 044610905755ca..a8e2f2c5b586f4 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: * ...