summaryrefslogtreecommitdiff
path: root/test/parallel/test-pending-deprecation.js
diff options
context:
space:
mode:
authorJames M Snell <jasnell@gmail.com>2017-03-11 12:18:53 -0800
committerJames M Snell <jasnell@gmail.com>2017-04-19 09:15:50 -0700
commita16b570f8c1283db81b85ff78ce73608a4265f61 (patch)
treebc1dd9d23003dfb32d81b8aadb7d36302e703f0b /test/parallel/test-pending-deprecation.js
parentd3dedb7223c54e77e7fa58c899070eaa4c3b2503 (diff)
downloadandroid-node-v8-a16b570f8c1283db81b85ff78ce73608a4265f61.tar.gz
android-node-v8-a16b570f8c1283db81b85ff78ce73608a4265f61.tar.bz2
android-node-v8-a16b570f8c1283db81b85ff78ce73608a4265f61.zip
src: add --pending-deprecation and NODE_PENDING_DEPRECATION
Command line flag and environment variable that can be used to indicate that pending deprecations should be emitted. PR-URL: https://github.com/nodejs/node/pull/11968 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'test/parallel/test-pending-deprecation.js')
-rw-r--r--test/parallel/test-pending-deprecation.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/test/parallel/test-pending-deprecation.js b/test/parallel/test-pending-deprecation.js
new file mode 100644
index 0000000000..402ec79b1b
--- /dev/null
+++ b/test/parallel/test-pending-deprecation.js
@@ -0,0 +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
+// 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: {NODE_PENDING_DEPRECATION: 1},
+ silent: true
+ }).on('exit', common.mustCall((code) => {
+ assert.strictEqual(code, 0, message('NODE_PENDING_DEPRECATION'));
+ }));
+}