@@ -11,38 +11,7 @@ const exec = require('child_process').execFile;
11
11
common . refreshTmpDir ( ) ;
12
12
process . chdir ( common . tmpDir ) ;
13
13
14
- disallow ( '--version' ) ;
15
- disallow ( '-v' ) ;
16
- disallow ( '--help' ) ;
17
- disallow ( '-h' ) ;
18
- disallow ( '--eval' ) ;
19
- disallow ( '-e' ) ;
20
- disallow ( '--print' ) ;
21
- disallow ( '-p' ) ;
22
- disallow ( '-pe' ) ;
23
- disallow ( '--check' ) ;
24
- disallow ( '-c' ) ;
25
- disallow ( '--interactive' ) ;
26
- disallow ( '-i' ) ;
27
- disallow ( '--v8-options' ) ;
28
- disallow ( '--' ) ;
29
- disallow ( '--no_warnings' ) ; // Node options don't allow '_' instead of '-'.
30
-
31
- function disallow ( opt ) {
32
- const options = { env : Object . assign ( { } , process . env ,
33
- { NODE_OPTIONS : opt } ) } ;
34
- exec ( process . execPath , options , common . mustCall ( function ( err ) {
35
- const message = err . message . split ( / \r ? \n / ) [ 1 ] ;
36
- const expect = `${ process . execPath } : ${ opt } is not allowed in NODE_OPTIONS` ;
37
-
38
- assert . strictEqual ( err . code , 9 ) ;
39
- assert . strictEqual ( message , expect ) ;
40
- } ) ) ;
41
- }
42
-
43
- const printA = require . resolve ( '../fixtures/printA.js' ) ;
44
-
45
- expect ( `-r ${ printA } ` , 'A\nB\n' ) ;
14
+ expect ( `-r ${ require . resolve ( '../fixtures/printA.js' ) } ` , 'A\nB\n' ) ;
46
15
expect ( '--no-deprecation' , 'B\n' ) ;
47
16
expect ( '--no-warnings' , 'B\n' ) ;
48
17
expect ( '--trace-warnings' , 'B\n' ) ;
@@ -54,33 +23,28 @@ expect('--track-heap-objects', 'B\n');
54
23
expect ( '--throw-deprecation' , 'B\n' ) ;
55
24
expect ( '--zero-fill-buffers' , 'B\n' ) ;
56
25
expect ( '--v8-pool-size=10' , 'B\n' ) ;
26
+
57
27
if ( common . hasCrypto ) {
58
28
expect ( '--use-openssl-ca' , 'B\n' ) ;
59
29
expect ( '--use-bundled-ca' , 'B\n' ) ;
60
30
expect ( '--openssl-config=_ossl_cfg' , 'B\n' ) ;
61
31
}
62
32
63
33
// V8 options
64
- expect ( '--abort-on-uncaught-exception' , 'B\n' ) ;
65
- expect ( '--abort_on_uncaught_exception' , 'B\n' ) ;
66
34
expect ( '--abort_on-uncaught_exception' , 'B\n' ) ;
67
- expect ( '--max_old_space_size=0' , 'B\n' ) ;
68
- expect ( '--max-old_space-size=0' , 'B\n' ) ;
69
35
expect ( '--max-old-space-size=0' , 'B\n' ) ;
70
36
71
37
function expect ( opt , want ) {
72
- const printB = require . resolve ( '../fixtures/printB.js' ) ;
73
- const argv = [ printB ] ;
38
+ const argv = [ '-e' , 'console.log("B")' ] ;
74
39
const opts = {
75
40
env : Object . assign ( { } , process . env , { NODE_OPTIONS : opt } ) ,
76
- maxBuffer : 1000000000 ,
41
+ maxBuffer : 1e6 ,
77
42
} ;
78
- exec ( process . execPath , argv , opts , common . mustCall ( function ( err , stdout ) {
43
+ exec ( process . execPath , argv , opts , common . mustCall ( ( err , stdout ) => {
79
44
assert . ifError ( err ) ;
80
- if ( ! RegExp ( want ) . test ( stdout ) ) {
81
- console . error ( 'For %j, failed to find %j in: <\n%s\n>' ,
82
- opt , want , stdout ) ;
83
- assert . fail ( `Expected ${ want } ` ) ;
84
- }
45
+ if ( stdout . includes ( want ) ) return ;
46
+
47
+ const o = JSON . stringify ( opt ) ;
48
+ assert . fail ( `For ${ o } , failed to find ${ want } in: <\n${ stdout } \n>` ) ;
85
49
} ) ) ;
86
50
}
0 commit comments