node/test/parallel/test-pending-deprecation.js
Gibson Fahnestock 180f86507d
test: remove envPlus, use Object.assign everywhere
PR-URL: https://github.com/nodejs/node/pull/14845
Fixes: https://github.com/nodejs/node/issues/14823
Refs: https://github.com/nodejs/node/pull/14822
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2017-09-03 17:28:50 -03:00

46 lines
1.5 KiB
JavaScript

'use strict';
// Tests that --pending-deprecation and NODE_PENDING_DEPRECATION both
// set the process.binding('config').pendingDeprecation flag that is
// used to determine if pending deprecation messages should be shown.
// The test is performed by launching two child processes that run
// this same test script with different arguments. If those exit with
// code 0, then the test passes. If they don't, it fails.
const common = require('../common');
const assert = require('assert');
const config = process.binding('config');
const fork = require('child_process').fork;
function message(name) {
return `${name} did not set the process.binding('config').` +
'pendingDeprecation flag.';
}
switch (process.argv[2]) {
case 'env':
case 'switch':
assert.strictEqual(config.pendingDeprecation, true);
break;
default:
// Verify that the flag is off by default.
assert.strictEqual(config.pendingDeprecation, undefined);
// Test the --pending-deprecation command line switch.
fork(__filename, ['switch'], {
execArgv: ['--pending-deprecation'],
silent: true
}).on('exit', common.mustCall((code) => {
assert.strictEqual(code, 0, message('--pending-deprecation'));
}));
// Test the NODE_PENDING_DEPRECATION environment var.
fork(__filename, ['env'], {
env: Object.assign({}, process.env, { NODE_PENDING_DEPRECATION: 1 }),
silent: true
}).on('exit', common.mustCall((code) => {
assert.strictEqual(code, 0, message('NODE_PENDING_DEPRECATION'));
}));
}