1
1
'use strict' ;
2
2
3
- // Tests that --pending-deprecation and NODE_PENDING_DEPRECATION both
4
- // set the process.binding('config').pendingDeprecation flag that is
5
- // used to determine if pending deprecation messages should be shown.
6
- // The test is performed by launching two child processes that run
3
+ // Flags: --expose-internals
4
+ // Tests that --pending-deprecation and NODE_PENDING_DEPRECATION both set the
5
+ // `require('internal/options').getOptionValue('--pending-deprecation')`
6
+ // flag that is used to determine if pending deprecation messages should be
7
+ // shown. The test is performed by launching two child processes that run
7
8
// this same test script with different arguments. If those exit with
8
9
// code 0, then the test passes. If they don't, it fails.
9
10
11
+ // TODO(joyeecheung): instead of testing internals, test the actual features
12
+ // pending deprecations.
13
+
10
14
const common = require ( '../common' ) ;
11
15
12
16
const assert = require ( 'assert' ) ;
13
- const config = process . binding ( 'config' ) ;
14
17
const fork = require ( 'child_process' ) . fork ;
18
+ const { getOptionValue } = require ( 'internal/options' ) ;
15
19
16
20
function message ( name ) {
17
- return `${ name } did not set the process.binding('config').` +
18
- 'pendingDeprecation flag.' ;
21
+ return `${ name } did not affect getOptionValue('--pending-deprecation')` ;
19
22
}
20
23
21
24
switch ( process . argv [ 2 ] ) {
22
25
case 'env' :
23
26
case 'switch' :
24
- assert . strictEqual ( config . pendingDeprecation , true ) ;
27
+ assert . strictEqual (
28
+ getOptionValue ( '--pending-deprecation' ) ,
29
+ true
30
+ ) ;
25
31
break ;
26
32
default :
27
33
// Verify that the flag is off by default.
28
34
const envvar = process . env . NODE_PENDING_DEPRECATION ;
29
- assert . strictEqual ( config . pendingDeprecation , envvar && envvar [ 0 ] === '1' ) ;
35
+ assert . strictEqual (
36
+ getOptionValue ( '--pending-deprecation' ) ,
37
+ ! ! ( envvar && envvar [ 0 ] === '1' )
38
+ ) ;
30
39
31
40
// Test the --pending-deprecation command line switch.
32
41
fork ( __filename , [ 'switch' ] , {
33
- execArgv : [ '--pending-deprecation' ] ,
42
+ execArgv : [ '--pending-deprecation' , '--expose-internals' ] ,
34
43
silent : true
35
44
} ) . on ( 'exit' , common . mustCall ( ( code ) => {
36
45
assert . strictEqual ( code , 0 , message ( '--pending-deprecation' ) ) ;
37
46
} ) ) ;
38
47
39
48
// Test the --pending_deprecation command line switch.
40
49
fork ( __filename , [ 'switch' ] , {
41
- execArgv : [ '--pending_deprecation' ] ,
50
+ execArgv : [ '--pending_deprecation' , '--expose-internals' ] ,
42
51
silent : true
43
52
} ) . on ( 'exit' , common . mustCall ( ( code ) => {
44
53
assert . strictEqual ( code , 0 , message ( '--pending_deprecation' ) ) ;
@@ -47,6 +56,7 @@ switch (process.argv[2]) {
47
56
// Test the NODE_PENDING_DEPRECATION environment var.
48
57
fork ( __filename , [ 'env' ] , {
49
58
env : Object . assign ( { } , process . env , { NODE_PENDING_DEPRECATION : 1 } ) ,
59
+ execArgv : [ '--expose-internals' ] ,
50
60
silent : true
51
61
} ) . on ( 'exit' , common . mustCall ( ( code ) => {
52
62
assert . strictEqual ( code , 0 , message ( 'NODE_PENDING_DEPRECATION' ) ) ;
0 commit comments