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 <rtrott@gmail.com> PR-URL: https://github.com/nodejs/node/pull/32141 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
192cb7288a
commit
66e32ff64a
@ -11,8 +11,7 @@ child.stderr.setEncoding('utf8');
|
|||||||
|
|
||||||
const expectedLines = [
|
const expectedLines = [
|
||||||
/^\(node:\d+\) \[DEP0068\] DeprecationWarning:/,
|
/^\(node:\d+\) \[DEP0068\] DeprecationWarning:/,
|
||||||
/^Usage: .*node.* debug script\.js$/,
|
/Usage: .*node.* debug script\.js\r?\n .*node.* debug <host>:<port>\r?\n .*node.* debug -p <pid>\r?\n$/,
|
||||||
/^ .*node.* debug <host>:<port>$/
|
|
||||||
];
|
];
|
||||||
|
|
||||||
let actualUsageMessage = '';
|
let actualUsageMessage = '';
|
||||||
@ -21,11 +20,10 @@ child.stderr.on('data', function(data) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
child.on('exit', common.mustCall(function(code) {
|
child.on('exit', common.mustCall(function(code) {
|
||||||
const outputLines = actualUsageMessage.split('\n');
|
|
||||||
assert.strictEqual(code, 1);
|
assert.strictEqual(code, 1);
|
||||||
for (let i = 0; i < expectedLines.length; i++)
|
for (let i = 0; i < expectedLines.length; i++)
|
||||||
assert.ok(
|
assert.ok(
|
||||||
expectedLines[i].test(outputLines[i]),
|
expectedLines[i].test(actualUsageMessage),
|
||||||
`${outputLines[i]} did not match ${expectedLines[i]}`
|
`${actualUsageMessage} did not match ${expectedLines[i]}`
|
||||||
);
|
);
|
||||||
}));
|
}));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user