Skip to content

Commit

Permalink
test: improve test-debug-usage
Browse files Browse the repository at this point in the history
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 <rtrott@gmail.com>

PR-URL: nodejs#32141
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
Trott committed Mar 10, 2020
1 parent 192cb72 commit 66e32ff
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions test/parallel/test-debug-usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ child.stderr.setEncoding('utf8');

const expectedLines = [
/^\(node:\d+\) \[DEP0068\] DeprecationWarning:/,
/^Usage: .*node.* debug script\.js$/,
/^ .*node.* debug <host>:<port>$/
/Usage: .*node.* debug script\.js\r?\n .*node.* debug <host>:<port>\r?\n .*node.* debug -p <pid>\r?\n$/,
];

let actualUsageMessage = '';
Expand All @@ -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]}`
);
}));

0 comments on commit 66e32ff

Please sign in to comment.