@@ -10,12 +10,14 @@ function runChecks(err, stdio, streamName, expected) {
1010 assert . deepStrictEqual ( stdio [ streamName ] , expected ) ;
1111}
1212
13+ const env = { NODE : process . execPath } ;
14+
1315// default value
1416{
1517 const cmd =
16- `" ${ process . execPath } " -e "console.log('a '.repeat(1024 * 1024))"` ;
18+ '"$NODE " -e "console.log(\'a\ '.repeat(1024 * 1024))"' ;
1719
18- cp . exec ( cmd , common . mustCall ( ( err ) => {
20+ cp . exec ( cmd , { env } , common . mustCall ( ( err ) => {
1921 assert ( err instanceof RangeError ) ;
2022 assert . strictEqual ( err . message , 'stdout maxBuffer length exceeded' ) ;
2123 assert . strictEqual ( err . code , 'ERR_CHILD_PROCESS_STDIO_MAXBUFFER' ) ;
@@ -25,17 +27,17 @@ function runChecks(err, stdio, streamName, expected) {
2527// default value
2628{
2729 const cmd =
28- ` ${ process . execPath } -e "console.log('a '.repeat(1024 * 1024 - 1))"` ;
30+ '"$NODE" -e "console.log(\'a\ '.repeat(1024 * 1024 - 1))"' ;
2931
30- cp . exec ( cmd , common . mustSucceed ( ( stdout , stderr ) => {
32+ cp . exec ( cmd , { env } , common . mustSucceed ( ( stdout , stderr ) => {
3133 assert . strictEqual ( stdout . trim ( ) , 'a' . repeat ( 1024 * 1024 - 1 ) ) ;
3234 assert . strictEqual ( stderr , '' ) ;
3335 } ) ) ;
3436}
3537
3638{
37- const cmd = `" ${ process . execPath } " -e "console.log('hello world');"` ;
38- const options = { maxBuffer : Infinity } ;
39+ const cmd = '"$NODE " -e "console.log(\ 'hello world\ ');"' ;
40+ const options = { env , maxBuffer : Infinity } ;
3941
4042 cp . exec ( cmd , options , common . mustSucceed ( ( stdout , stderr ) => {
4143 assert . strictEqual ( stdout . trim ( ) , 'hello world' ) ;
@@ -58,10 +60,11 @@ function runChecks(err, stdio, streamName, expected) {
5860// default value
5961{
6062 const cmd =
61- `" ${ process . execPath } " -e "console.log('a '.repeat(1024 * 1024))"` ;
63+ '"$NODE " -e "console.log(\'a\ '.repeat(1024 * 1024))"' ;
6264
6365 cp . exec (
6466 cmd ,
67+ { env } ,
6568 common . mustCall ( ( err , stdout , stderr ) => {
6669 runChecks (
6770 err ,
@@ -76,9 +79,9 @@ function runChecks(err, stdio, streamName, expected) {
7679// default value
7780{
7881 const cmd =
79- `" ${ process . execPath } " -e "console.log('a '.repeat(1024 * 1024 - 1))"` ;
82+ '"$NODE " -e "console.log(\'a\ '.repeat(1024 * 1024 - 1))"' ;
8083
81- cp . exec ( cmd , common . mustSucceed ( ( stdout , stderr ) => {
84+ cp . exec ( cmd , { env } , common . mustSucceed ( ( stdout , stderr ) => {
8285 assert . strictEqual ( stdout . trim ( ) , 'a' . repeat ( 1024 * 1024 - 1 ) ) ;
8386 assert . strictEqual ( stderr , '' ) ;
8487 } ) ) ;
@@ -87,35 +90,35 @@ function runChecks(err, stdio, streamName, expected) {
8790const unicode = '中文测试' ; // length = 4, byte length = 12
8891
8992{
90- const cmd = `"${ process . execPath } " -e "console.log('${ unicode } ');"` ;
93+ const cmd = `"$NODE " -e "console.log('${ unicode } ');"` ;
9194
9295 cp . exec (
9396 cmd ,
94- { maxBuffer : 10 } ,
97+ { env , maxBuffer : 10 } ,
9598 common . mustCall ( ( err , stdout , stderr ) => {
9699 runChecks ( err , { stdout, stderr } , 'stdout' , '中文测试\n' ) ;
97100 } )
98101 ) ;
99102}
100103
101104{
102- const cmd = `"${ process . execPath } " -e "console.error('${ unicode } ');"` ;
105+ const cmd = `"$NODE " -e "console.error('${ unicode } ');"` ;
103106
104107 cp . exec (
105108 cmd ,
106- { maxBuffer : 3 } ,
109+ { env , maxBuffer : 3 } ,
107110 common . mustCall ( ( err , stdout , stderr ) => {
108111 runChecks ( err , { stdout, stderr } , 'stderr' , '中文测' ) ;
109112 } )
110113 ) ;
111114}
112115
113116{
114- const cmd = `"${ process . execPath } " -e "console.log('${ unicode } ');"` ;
117+ const cmd = `"$NODE " -e "console.log('${ unicode } ');"` ;
115118
116119 const child = cp . exec (
117120 cmd ,
118- { encoding : null , maxBuffer : 10 } ,
121+ { encoding : null , env , maxBuffer : 10 } ,
119122 common . mustCall ( ( err , stdout , stderr ) => {
120123 runChecks ( err , { stdout, stderr } , 'stdout' , '中文测试\n' ) ;
121124 } )
@@ -125,11 +128,11 @@ const unicode = '中文测试'; // length = 4, byte length = 12
125128}
126129
127130{
128- const cmd = `"${ process . execPath } " -e "console.error('${ unicode } ');"` ;
131+ const cmd = `"$NODE " -e "console.error('${ unicode } ');"` ;
129132
130133 const child = cp . exec (
131134 cmd ,
132- { encoding : null , maxBuffer : 3 } ,
135+ { encoding : null , env , maxBuffer : 3 } ,
133136 common . mustCall ( ( err , stdout , stderr ) => {
134137 runChecks ( err , { stdout, stderr } , 'stderr' , '中文测' ) ;
135138 } )
@@ -139,11 +142,11 @@ const unicode = '中文测试'; // length = 4, byte length = 12
139142}
140143
141144{
142- const cmd = `"${ process . execPath } " -e "console.error('${ unicode } ');"` ;
145+ const cmd = `"$NODE " -e "console.error('${ unicode } ');"` ;
143146
144147 cp . exec (
145148 cmd ,
146- { encoding : null , maxBuffer : 5 } ,
149+ { encoding : null , env , maxBuffer : 5 } ,
147150 common . mustCall ( ( err , stdout , stderr ) => {
148151 const buf = Buffer . from ( unicode ) . slice ( 0 , 5 ) ;
149152 runChecks ( err , { stdout, stderr } , 'stderr' , buf ) ;
0 commit comments