@@ -6,7 +6,10 @@ if (process.config.variables.node_without_node_options)
6
6
// Test options specified by env variable.
7
7
8
8
const assert = require ( 'assert' ) ;
9
- const exec = require ( 'child_process' ) . execFile ;
9
+ // Don't change this to execFile(). This test launches too many processes for
10
+ // underpowered machines in CI with limited PID space to launch them in parallel
11
+ // without causing failures.
12
+ const { execFileSync } = require ( 'child_process' ) ;
10
13
11
14
const tmpdir = require ( '../common/tmpdir' ) ;
12
15
tmpdir . refresh ( ) ;
@@ -56,7 +59,7 @@ if (common.hasCrypto) {
56
59
expect ( '--abort_on-uncaught_exception' , 'B\n' ) ;
57
60
expect ( '--max-old-space-size=0' , 'B\n' ) ;
58
61
expect ( '--stack-trace-limit=100' ,
59
- / ( \s * a t f \( \[ e v a l \] : 1 : \d * \) \r ? \n ) { 100 } / ,
62
+ / ( \s * a t f \( \[ e v a l \] : 1 : \d + \) \r ? \n ) { 100 } / ,
60
63
'(function f() { f(); })();' ,
61
64
true ) ;
62
65
@@ -66,18 +69,23 @@ function expect(opt, want, command = 'console.log("B")', wantsError = false) {
66
69
cwd : tmpdir . path ,
67
70
env : Object . assign ( { } , process . env , { NODE_OPTIONS : opt } ) ,
68
71
maxBuffer : 1e6 ,
72
+ stdio : 'pipe' ,
69
73
} ;
74
+
70
75
if ( typeof want === 'string' )
71
76
want = new RegExp ( want ) ;
72
- exec ( process . execPath , argv , opts , common . mustCall ( ( err , stdout , stderr ) => {
73
- if ( wantsError ) {
74
- stdout = stderr ;
75
- } else {
76
- assert . ifError ( err ) ;
77
- }
78
- if ( want . test ( stdout ) ) return ;
79
77
80
- const o = JSON . stringify ( opt ) ;
81
- assert . fail ( `For ${ o } , failed to find ${ want } in: <\n${ stdout } \n>` ) ;
82
- } ) ) ;
78
+ let stdout ;
79
+ try {
80
+ stdout = execFileSync ( process . execPath , argv , opts ) ;
81
+ } catch ( e ) {
82
+ if ( ! wantsError )
83
+ throw e ;
84
+ stdout = e . output [ 2 ] . toString ( ) ;
85
+ }
86
+
87
+ if ( want . test ( stdout ) ) return ;
88
+
89
+ const o = JSON . stringify ( opt ) ;
90
+ assert . fail ( `For ${ o } , failed to find ${ want } in: <\n${ stdout } \n>` ) ;
83
91
}
0 commit comments