Skip to content

Commit

Permalink
test: remove common.noWarnCode
Browse files Browse the repository at this point in the history
This property was just sugar for `undefined` and did not check much.
Now that we properly check that a DeprecationWarning requires a code
we do not have to check that a code is always present.
  • Loading branch information
BridgeAR committed Dec 28, 2018
1 parent 3d579f6 commit b84f495
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 59 deletions.
10 changes: 2 additions & 8 deletions test/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,7 @@ Indicates if there is more than 1gb of total memory.
* `expected` [<string>] | [<Array>] | [<Object>]
* `code` [<string>]

Tests whether `name`, `expected`, and `code` are part of a raised warning. If
an expected warning does not have a code then `common.noWarnCode` can be used
to indicate this.
Tests whether `name`, `expected`, and `code` are part of a raised warning.

The code is required in case the name is set to `'DeprecationWarning'`.

Expand All @@ -135,7 +133,7 @@ expectWarning('DeprecationWarning', [

expectWarning('DeprecationWarning', [
['Foobar is deprecated', 'DEP0XXX'],
['Baz is also deprecated', noWarnCode]
['Baz is also deprecated']
]);

expectWarning('DeprecationWarning', {
Expand All @@ -149,7 +147,6 @@ expectWarning({
DEP0XX1: 'Baz is also deprecated'
},
Warning: [
['Foobar', noWarnCode],
['Multiple array entries are fine', 'DEP0XXX'],
['No code is also fine']
],
Expand Down Expand Up @@ -302,9 +299,6 @@ Returns `true` if the exit code `exitCode` and/or signal name `signal` represent
the exit code and/or signal name of a node process that aborted, `false`
otherwise.

### noWarnCode
See `common.expectWarning()` for usage.

### opensslCli
* [<boolean>]

Expand Down
1 change: 0 additions & 1 deletion test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,6 @@ module.exports = {
mustCallAtLeast,
mustNotCall,
nodeProcessAborted,
noWarnCode: undefined,
PIPE,
platformTimeout,
printSkipMessage,
Expand Down
2 changes: 0 additions & 2 deletions test/common/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const {
nodeProcessAborted,
busyLoop,
isAlive,
noWarnCode,
expectWarning,
expectsError,
skipIfInspectorDisabled,
Expand Down Expand Up @@ -84,7 +83,6 @@ export {
nodeProcessAborted,
busyLoop,
isAlive,
noWarnCode,
expectWarning,
expectsError,
skipIfInspectorDisabled,
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-atomics-notify.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

const { expectWarning, noWarnCode } = require('../common');
const { expectWarning } = require('../common');

const assert = require('assert');
const { runInNewContext } = require('vm');
Expand All @@ -14,6 +14,6 @@ assert.strictEqual(runInNewContext('typeof Atomics.notify'), 'function');
expectWarning(
'Atomics',
'Atomics.wake will be removed in a future version, ' +
'use Atomics.notify instead.', noWarnCode);
'use Atomics.notify instead.');

Atomics.wake(new Int32Array(new SharedArrayBuffer(4)), 0, 0);
16 changes: 8 additions & 8 deletions test/parallel/test-console.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ if (common.isMainThread) {
common.expectWarning(
'Warning',
[
['Count for \'noLabel\' does not exist', common.noWarnCode],
['No such label \'noLabel\' for console.timeLog()', common.noWarnCode],
['No such label \'noLabel\' for console.timeEnd()', common.noWarnCode],
['Count for \'default\' does not exist', common.noWarnCode],
['No such label \'default\' for console.timeLog()', common.noWarnCode],
['No such label \'default\' for console.timeEnd()', common.noWarnCode],
['Label \'default\' already exists for console.time()', common.noWarnCode],
['Label \'test\' already exists for console.time()', common.noWarnCode]
['Count for \'noLabel\' does not exist'],
['No such label \'noLabel\' for console.timeLog()'],
['No such label \'noLabel\' for console.timeEnd()'],
['Count for \'default\' does not exist'],
['No such label \'default\' for console.timeLog()'],
['No such label \'default\' for console.timeEnd()'],
['Label \'default\' already exists for console.time()'],
['Label \'test\' already exists for console.time()']
]
);

Expand Down
38 changes: 19 additions & 19 deletions test/parallel/test-crypto-authenticated.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,25 @@ const ciphers = crypto.getCiphers();

const expectedWarnings = common.hasFipsCrypto ?
[] : [
['Use Cipheriv for counter mode of aes-192-gcm', common.noWarnCode],
['Use Cipheriv for counter mode of aes-192-ccm', common.noWarnCode],
['Use Cipheriv for counter mode of aes-192-ccm', common.noWarnCode],
['Use Cipheriv for counter mode of aes-128-ccm', common.noWarnCode],
['Use Cipheriv for counter mode of aes-128-ccm', common.noWarnCode],
['Use Cipheriv for counter mode of aes-128-ccm', common.noWarnCode],
['Use Cipheriv for counter mode of aes-256-ccm', common.noWarnCode],
['Use Cipheriv for counter mode of aes-256-ccm', common.noWarnCode],
['Use Cipheriv for counter mode of aes-256-ccm', common.noWarnCode],
['Use Cipheriv for counter mode of aes-256-ccm', common.noWarnCode],
['Use Cipheriv for counter mode of aes-256-ccm', common.noWarnCode],
['Use Cipheriv for counter mode of aes-256-ccm', common.noWarnCode],
['Use Cipheriv for counter mode of aes-256-ccm', common.noWarnCode],
['Use Cipheriv for counter mode of aes-256-ccm', common.noWarnCode],
['Use Cipheriv for counter mode of aes-256-ccm', common.noWarnCode],
['Use Cipheriv for counter mode of aes-256-ccm', common.noWarnCode],
['Use Cipheriv for counter mode of aes-256-ccm', common.noWarnCode],
['Use Cipheriv for counter mode of aes-256-ccm', common.noWarnCode],
['Use Cipheriv for counter mode of aes-256-ccm', common.noWarnCode]
['Use Cipheriv for counter mode of aes-192-gcm'],
['Use Cipheriv for counter mode of aes-192-ccm'],
['Use Cipheriv for counter mode of aes-192-ccm'],
['Use Cipheriv for counter mode of aes-128-ccm'],
['Use Cipheriv for counter mode of aes-128-ccm'],
['Use Cipheriv for counter mode of aes-128-ccm'],
['Use Cipheriv for counter mode of aes-256-ccm'],
['Use Cipheriv for counter mode of aes-256-ccm'],
['Use Cipheriv for counter mode of aes-256-ccm'],
['Use Cipheriv for counter mode of aes-256-ccm'],
['Use Cipheriv for counter mode of aes-256-ccm'],
['Use Cipheriv for counter mode of aes-256-ccm'],
['Use Cipheriv for counter mode of aes-256-ccm'],
['Use Cipheriv for counter mode of aes-256-ccm'],
['Use Cipheriv for counter mode of aes-256-ccm'],
['Use Cipheriv for counter mode of aes-256-ccm'],
['Use Cipheriv for counter mode of aes-256-ccm'],
['Use Cipheriv for counter mode of aes-256-ccm'],
['Use Cipheriv for counter mode of aes-256-ccm']
];

const expectedDeprecationWarnings = [
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-crypto-cipher-decipher.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const assert = require('assert');

common.expectWarning({
Warning: [
['Use Cipheriv for counter mode of aes-256-gcm', common.noWarnCode]
['Use Cipheriv for counter mode of aes-256-gcm']
],
DeprecationWarning: [
['crypto.createCipher is deprecated.', 'DEP0106']
Expand Down
6 changes: 2 additions & 4 deletions test/parallel/test-fs-filehandle.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@ let fdnum;

common.expectWarning({
'internal/test/binding': [
'These APIs are for internal testing only. Do not use them.',
common.noWarnCode
'These APIs are for internal testing only. Do not use them.'
],
'Warning': [
`Closing file descriptor ${fdnum} on garbage collection`,
common.noWarnCode
`Closing file descriptor ${fdnum} on garbage collection`
]
});

Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-https-strict.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ common.expectWarning(
'Warning',
'Setting the NODE_TLS_REJECT_UNAUTHORIZED environment variable to \'0\' ' +
'makes TLS connections and HTTPS requests insecure by disabling ' +
'certificate verification.',
common.noWarnCode
'certificate verification.'
);

const assert = require('assert');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-process-emit-warning-from-native.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const key = '0123456789';
['crypto.createCipher is deprecated.', 'DEP0106']
],
Warning: [
['Use Cipheriv for counter mode of aes-256-gcm', common.noWarnCode]
['Use Cipheriv for counter mode of aes-256-gcm']
]
});

Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-promises-unhandled-proxy-rejections.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const expectedPromiseWarning = ['Unhandled promise rejection. ' +
'This error originated either by throwing ' +
'inside of an async function without a catch ' +
'block, or by rejecting a promise which was ' +
'not handled with .catch(). (rejection id: 1)', common.noWarnCode];
'not handled with .catch(). (rejection id: 1)'];

function throwErr() {
throw new Error('Error from proxy');
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-promises-unhandled-symbol-rejections.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const common = require('../common');

common.disableCrashOnUnhandledRejection();

const expectedValueWarning = ['Symbol()', common.noWarnCode];
const expectedValueWarning = ['Symbol()'];
const expectedDeprecationWarning = ['Unhandled promise rejections are ' +
'deprecated. In the future, promise ' +
'rejections that are not handled will ' +
Expand All @@ -13,7 +13,7 @@ const expectedPromiseWarning = ['Unhandled promise rejection. ' +
'This error originated either by throwing ' +
'inside of an async function without a catch ' +
'block, or by rejecting a promise which was ' +
'not handled with .catch(). (rejection id: 1)', common.noWarnCode];
'not handled with .catch(). (rejection id: 1)'];

common.expectWarning({
DeprecationWarning: expectedDeprecationWarning,
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-tls-dhe.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ const ciphers = 'DHE-RSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';

// Test will emit a warning because the DH parameter size is < 2048 bits
common.expectWarning('SecurityWarning',
'DH parameter is less than 2048 bits',
common.noWarnCode);
'DH parameter is less than 2048 bits');

function loadDHParam(n) {
const params = [`dh${n}.pem`];
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-trace-events-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ if (isChild) {
common.expectWarning(
'Warning',
'Possible trace_events memory leak detected. There are more than ' +
'10 enabled Tracing objects.',
common.noWarnCode);
'10 enabled Tracing objects.');
for (let n = 0; n < 10; n++) {
const tracing = createTracing({ categories: [ `a${n}` ] });
tracing.enable();
Expand Down
3 changes: 1 addition & 2 deletions test/parallel/test-warn-sigprof.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ if (common.isWindows)
common.skipIfWorker(); // Worker inspector never has a server running

common.expectWarning('Warning',
'process.on(SIGPROF) is reserved while debugging',
common.noWarnCode);
'process.on(SIGPROF) is reserved while debugging');

process.on('SIGPROF', () => {});
3 changes: 1 addition & 2 deletions test/parallel/test-worker-message-port-transfer-target.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ const arrayBuf = new ArrayBuffer(10);

common.expectWarning('Warning',
'The target port was posted to itself, and the ' +
'communication channel was lost',
common.noWarnCode);
'communication channel was lost');
port2.onmessage = common.mustNotCall();
port2.postMessage(null, [port1, arrayBuf]);

Expand Down

0 comments on commit b84f495

Please sign in to comment.