Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1733ef9

Browse filesBrowse files
tniessenMylesBorins
authored andcommitted
test: make handling of noWarnCode stricter
This change requires all expected warnings to be specified along with their respective code and will raise an error if the code does not match. This also kind of fixes the behavior when the expected warning code was noWarnCode and there is an actual warning code. PR-URL: #21075 Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent ba71fe8 commit 1733ef9
Copy full SHA for 1733ef9

File tree

Expand file treeCollapse file tree

3 files changed

+7
-14
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+7
-14
lines changed
Open diff view settings
Collapse file

‎test/common/index.js‎

Copy file name to clipboardExpand all lines: test/common/index.js
+2-9Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ exports.isAlive = function isAlive(pid) {
589589
}
590590
};
591591

592-
exports.noWarnCode = 'no_expected_warning_code';
592+
exports.noWarnCode = undefined;
593593

594594
function expectWarning(name, expected) {
595595
const map = new Map(expected);
@@ -598,14 +598,7 @@ function expectWarning(name, expected) {
598598
assert.ok(map.has(warning.message),
599599
`unexpected error message: "${warning.message}"`);
600600
const code = map.get(warning.message);
601-
if (code === undefined) {
602-
throw new Error('An error code must be specified or use ' +
603-
'common.noWarnCode if there is no error code. The error ' +
604-
`code for this warning was ${warning.code}`);
605-
}
606-
if (code !== exports.noWarnCode) {
607-
assert.strictEqual(warning.code, code);
608-
}
601+
assert.strictEqual(warning.code, code);
609602
// Remove a warning message after it is seen so that we guarantee that we
610603
// get each message only once.
611604
map.delete(expected);
Collapse file

‎test/parallel/test-promises-unhandled-symbol-rejections.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-promises-unhandled-symbol-rejections.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const expectedDeprecationWarning = ['Unhandled promise rejections are ' +
66
'deprecated. In the future, promise ' +
77
'rejections that are not handled will ' +
88
'terminate the Node.js process with a ' +
9-
'non-zero exit code.', common.noWarnCode];
9+
'non-zero exit code.', 'DEP0018'];
1010
const expectedPromiseWarning = ['Unhandled promise rejection. ' +
1111
'This error originated either by throwing ' +
1212
'inside of an async function without a catch ' +
Collapse file

‎test/parallel/test-util.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-util.js
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,10 @@ assert.strictEqual(util.isFunction(), false);
142142
assert.strictEqual(util.isFunction('string'), false);
143143

144144
common.expectWarning('DeprecationWarning', [
145-
['util.print is deprecated. Use console.log instead.', common.noWarnCode],
146-
['util.puts is deprecated. Use console.log instead.', common.noWarnCode],
147-
['util.debug is deprecated. Use console.error instead.', common.noWarnCode],
148-
['util.error is deprecated. Use console.error instead.', common.noWarnCode]
145+
['util.print is deprecated. Use console.log instead.', 'DEP0026'],
146+
['util.puts is deprecated. Use console.log instead.', 'DEP0027'],
147+
['util.debug is deprecated. Use console.error instead.', 'DEP0028'],
148+
['util.error is deprecated. Use console.error instead.', 'DEP0029']
149149
]);
150150

151151
util.print('test');

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.