From bb947ce3c2515a02a80eccfe531b9f9e9f392ba2 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Sat, 7 Mar 2020 17:04:15 -0800 Subject: [PATCH] test: improve test-debug-usage test-debug-usage fails if run with `--trace-warnings` because the regular expression checking does not allow for the resulting stack trace from the deprecation warning. The test also only tests two parts of the three-part usage message. Improve the test so that it passes with `--trace-warnings` and verifies all three parts of the usage message. Signed-off-by: Rich Trott PR-URL: https://github.com/nodejs/node/pull/32141 Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater --- test/parallel/test-debug-usage.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-debug-usage.js b/test/parallel/test-debug-usage.js index 4582ac7bb5b6e2..eb9594f236b35c 100644 --- a/test/parallel/test-debug-usage.js +++ b/test/parallel/test-debug-usage.js @@ -11,8 +11,7 @@ child.stderr.setEncoding('utf8'); const expectedLines = [ /^\(node:\d+\) \[DEP0068\] DeprecationWarning:/, - /^Usage: .*node.* debug script\.js$/, - /^ .*node.* debug :$/ + /Usage: .*node.* debug script\.js\r?\n .*node.* debug :\r?\n .*node.* debug -p \r?\n$/, ]; let actualUsageMessage = ''; @@ -21,11 +20,10 @@ child.stderr.on('data', function(data) { }); child.on('exit', common.mustCall(function(code) { - const outputLines = actualUsageMessage.split('\n'); assert.strictEqual(code, 1); for (let i = 0; i < expectedLines.length; i++) assert.ok( - expectedLines[i].test(outputLines[i]), - `${outputLines[i]} did not match ${expectedLines[i]}` + expectedLines[i].test(actualUsageMessage), + `${actualUsageMessage} did not match ${expectedLines[i]}` ); }));