diff options
author | Tobias Nießen <tniessen@tnie.de> | 2018-05-31 17:21:59 +0200 |
---|---|---|
committer | Tobias Nießen <tniessen@tnie.de> | 2018-06-04 13:51:19 +0200 |
commit | 41843e23f260eccf1e4a3be8ed9e429fa4b87ea5 (patch) | |
tree | 993dd43d023d82d8c40989fb752e26a11a58682d /test | |
parent | 5a6b1975d553f4f02cb37b287532c4268328ea31 (diff) | |
download | node-new-41843e23f260eccf1e4a3be8ed9e429fa4b87ea5.tar.gz |
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: https://github.com/nodejs/node/pull/21075
Reviewed-By: Daniel Bevenius <daniel.bevenius@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/common/index.js | 11 | ||||
-rw-r--r-- | test/parallel/test-promises-unhandled-symbol-rejections.js | 2 | ||||
-rw-r--r-- | test/parallel/test-util.js | 8 |
3 files changed, 7 insertions, 14 deletions
diff --git a/test/common/index.js b/test/common/index.js index 85d11ec093..f76e1cd38c 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -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); @@ -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); diff --git a/test/parallel/test-promises-unhandled-symbol-rejections.js b/test/parallel/test-promises-unhandled-symbol-rejections.js index 5c028a74c2..e5084b50c1 100644 --- a/test/parallel/test-promises-unhandled-symbol-rejections.js +++ b/test/parallel/test-promises-unhandled-symbol-rejections.js @@ -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 ' + diff --git a/test/parallel/test-util.js b/test/parallel/test-util.js index ee2fe917f3..337cb789f7 100644 --- a/test/parallel/test-util.js +++ b/test/parallel/test-util.js @@ -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'); |