Skip to content

Commit 188f1d2

Browse files
TrottMylesBorins
authored andcommitted
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 <[email protected]> PR-URL: #32141 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent bb41383 commit 188f1d2

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

test/parallel/test-debug-usage.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ child.stderr.setEncoding('utf8');
1111

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

1817
let actualUsageMessage = '';
@@ -21,11 +20,10 @@ child.stderr.on('data', function(data) {
2120
});
2221

2322
child.on('exit', common.mustCall(function(code) {
24-
const outputLines = actualUsageMessage.split('\n');
2523
assert.strictEqual(code, 1);
2624
for (let i = 0; i < expectedLines.length; i++)
2725
assert.ok(
28-
expectedLines[i].test(outputLines[i]),
29-
`${outputLines[i]} did not match ${expectedLines[i]}`
26+
expectedLines[i].test(actualUsageMessage),
27+
`${actualUsageMessage} did not match ${expectedLines[i]}`
3028
);
3129
}));

0 commit comments

Comments
 (0)