Skip to content

test: make handling of noWarnCode stricter #21075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ exports.isAlive = function isAlive(pid) {
}
};

exports.noWarnCode = 'no_expected_warning_code';
exports.noWarnCode = undefined;

function expectWarning(name, expected) {
const map = new Map(expected);
Expand All @@ -598,14 +598,7 @@ function expectWarning(name, expected) {
assert.ok(map.has(warning.message),
`unexpected error message: "${warning.message}"`);
const code = map.get(warning.message);
if (code === undefined) {
throw new Error('An error code must be specified or use ' +
'common.noWarnCode if there is no error code. The error ' +
`code for this warning was ${warning.code}`);
}
if (code !== exports.noWarnCode) {
assert.strictEqual(warning.code, code);
}
assert.strictEqual(warning.code, code);
// Remove a warning message after it is seen so that we guarantee that we
// get each message only once.
map.delete(expected);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-promises-unhandled-symbol-rejections.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const expectedDeprecationWarning = ['Unhandled promise rejections are ' +
'deprecated. In the future, promise ' +
'rejections that are not handled will ' +
'terminate the Node.js process with a ' +
'non-zero exit code.', common.noWarnCode];
'non-zero exit code.', 'DEP0018'];
const expectedPromiseWarning = ['Unhandled promise rejection. ' +
'This error originated either by throwing ' +
'inside of an async function without a catch ' +
Expand Down
8 changes: 4 additions & 4 deletions test/parallel/test-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,10 @@ assert.strictEqual(util.isFunction(), false);
assert.strictEqual(util.isFunction('string'), false);

common.expectWarning('DeprecationWarning', [
['util.print is deprecated. Use console.log instead.', common.noWarnCode],
['util.puts is deprecated. Use console.log instead.', common.noWarnCode],
['util.debug is deprecated. Use console.error instead.', common.noWarnCode],
['util.error is deprecated. Use console.error instead.', common.noWarnCode]
['util.print is deprecated. Use console.log instead.', 'DEP0026'],
['util.puts is deprecated. Use console.log instead.', 'DEP0027'],
['util.debug is deprecated. Use console.error instead.', 'DEP0028'],
['util.error is deprecated. Use console.error instead.', 'DEP0029']
]);

util.print('test');
Expand Down