summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/buffer.js6
-rw-r--r--lib/internal/bootstrap/node.js2
-rw-r--r--src/node_config.cc3
-rw-r--r--test/parallel/test-pending-deprecation.js32
4 files changed, 24 insertions, 19 deletions
diff --git a/lib/buffer.js b/lib/buffer.js
index b032736f50..019969acd1 100644
--- a/lib/buffer.js
+++ b/lib/buffer.js
@@ -48,9 +48,7 @@ const {
isArrayBufferView,
isUint8Array
} = require('internal/util/types');
-const {
- pendingDeprecation
-} = internalBinding('config');
+
const {
ERR_BUFFER_OUT_OF_BOUNDS,
ERR_OUT_OF_RANGE,
@@ -138,7 +136,7 @@ const bufferWarning = 'Buffer() is deprecated due to security and usability ' +
function showFlaggedDeprecation() {
if (bufferWarningAlreadyEmitted ||
++nodeModulesCheckCounter > 10000 ||
- (!pendingDeprecation &&
+ (!require('internal/options').getOptionValue('--pending-deprecation') &&
isInsideNodeModules())) {
// We don't emit a warning, because we either:
// - Already did so, or
diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js
index 31ab0f986c..fd503421ff 100644
--- a/lib/internal/bootstrap/node.js
+++ b/lib/internal/bootstrap/node.js
@@ -176,7 +176,7 @@ function startup() {
{
// Install legacy getters on the `util` binding for typechecking.
// TODO(addaleax): Turn into a full runtime deprecation.
- const { pendingDeprecation } = internalBinding('config');
+ const pendingDeprecation = getOptionValue('--pending-deprecation');
const utilBinding = internalBinding('util');
const types = internalBinding('types');
for (const name of [
diff --git a/src/node_config.cc b/src/node_config.cc
index a8ffac2cc1..1ba1fe9d27 100644
--- a/src/node_config.cc
+++ b/src/node_config.cc
@@ -77,9 +77,6 @@ static void Initialize(Local<Object> target,
if (env->options()->experimental_repl_await)
READONLY_TRUE_PROPERTY(target, "experimentalREPLAwait");
- if (env->options()->pending_deprecation)
- READONLY_TRUE_PROPERTY(target, "pendingDeprecation");
-
if (env->options()->expose_internals)
READONLY_TRUE_PROPERTY(target, "exposeInternals");
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'));