diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2018-12-12 01:24:59 +0800 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2018-12-14 21:22:59 -0800 |
commit | b32e5e08b2c6dc1390d4bab1fe4e2d3670d251c8 (patch) | |
tree | af5a2536040caa404476ad4bc250ac7a6e6ae3f2 /test | |
parent | 6a24014ee5050c81b5e86ea6f0107494e126a027 (diff) | |
download | android-node-v8-b32e5e08b2c6dc1390d4bab1fe4e2d3670d251c8.tar.gz android-node-v8-b32e5e08b2c6dc1390d4bab1fe4e2d3670d251c8.tar.bz2 android-node-v8-b32e5e08b2c6dc1390d4bab1fe4e2d3670d251c8.zip |
lib: remove internalBinding('config').pendingDeprecation
Instead use
`require('internal/options').getOptionValue('--pending-deprecation')`
PR-URL: https://github.com/nodejs/node/pull/24962
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test')
-rw-r--r-- | test/parallel/test-pending-deprecation.js | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/test/parallel/test-pending-deprecation.js b/test/parallel/test-pending-deprecation.js index bb11d84bcc..6cabf9ddc6 100644 --- a/test/parallel/test-pending-deprecation.js +++ b/test/parallel/test-pending-deprecation.js @@ -1,36 +1,45 @@ '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 +// Flags: --expose-internals +// Tests that --pending-deprecation and NODE_PENDING_DEPRECATION both set the +// `require('internal/options').getOptionValue('--pending-deprecation')` +// 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. +// TODO(joyeecheung): instead of testing internals, test the actual features +// pending deprecations. + const common = require('../common'); const assert = require('assert'); -const config = process.binding('config'); const fork = require('child_process').fork; +const { getOptionValue } = require('internal/options'); function message(name) { - return `${name} did not set the process.binding('config').` + - 'pendingDeprecation flag.'; + return `${name} did not affect getOptionValue('--pending-deprecation')`; } switch (process.argv[2]) { case 'env': case 'switch': - assert.strictEqual(config.pendingDeprecation, true); + assert.strictEqual( + getOptionValue('--pending-deprecation'), + true + ); break; default: // Verify that the flag is off by default. const envvar = process.env.NODE_PENDING_DEPRECATION; - assert.strictEqual(config.pendingDeprecation, envvar && envvar[0] === '1'); + assert.strictEqual( + getOptionValue('--pending-deprecation'), + !!(envvar && envvar[0] === '1') + ); // Test the --pending-deprecation command line switch. fork(__filename, ['switch'], { - execArgv: ['--pending-deprecation'], + execArgv: ['--pending-deprecation', '--expose-internals'], silent: true }).on('exit', common.mustCall((code) => { assert.strictEqual(code, 0, message('--pending-deprecation')); @@ -38,7 +47,7 @@ switch (process.argv[2]) { // Test the --pending_deprecation command line switch. fork(__filename, ['switch'], { - execArgv: ['--pending_deprecation'], + execArgv: ['--pending_deprecation', '--expose-internals'], silent: true }).on('exit', common.mustCall((code) => { assert.strictEqual(code, 0, message('--pending_deprecation')); @@ -47,6 +56,7 @@ switch (process.argv[2]) { // Test the NODE_PENDING_DEPRECATION environment var. fork(__filename, ['env'], { env: Object.assign({}, process.env, { NODE_PENDING_DEPRECATION: 1 }), + execArgv: ['--expose-internals'], silent: true }).on('exit', common.mustCall((code) => { assert.strictEqual(code, 0, message('NODE_PENDING_DEPRECATION')); |