-
Notifications
You must be signed in to change notification settings - Fork 30k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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: #11968 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Michaël Zasso <[email protected]> Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: Сковорода Никита Андреевич <[email protected]> Reviewed-By: James M Snell <[email protected]>
- Loading branch information
Showing
6 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')); | ||
})); | ||
} |