@@ -1072,26 +1072,40 @@ test('Falls back to transpileOnly when ts compiler returns emitSkipped', async (
10721072} ) ;
10731073
10741074test . suite ( 'node environment' , ( test ) => {
1075- test ( 'Sets argv and execArgv correctly in forked processes' , async ( t ) => {
1076- const { err, stderr, stdout } = await exec (
1077- `node --no-warnings ${ BIN_PATH } --skipIgnore ./recursive-fork/index.ts argv2`
1075+ test . suite ( 'Sets argv and execArgv correctly in forked processes' , ( test ) => {
1076+ forkTest ( `node --no-warnings ${ BIN_PATH_JS } ` , BIN_PATH_JS , '--no-warnings' ) ;
1077+ forkTest (
1078+ `${ BIN_PATH } ` ,
1079+ process . platform === 'win32' ? BIN_PATH_JS : BIN_PATH
10781080 ) ;
1079- expect ( err ) . toBeNull ( ) ;
1080- expect ( stderr ) . toBe ( '' ) ;
1081- const generations = stdout . split ( '\n' ) ;
1082- const expectation = {
1083- execArgv : [ '--no-warnings' , BIN_PATH_JS , '--skipIgnore' ] ,
1084- argv : [
1085- // Note: argv[0] is BIN_PATH in parent, BIN_PATH_JS in child & grandchild
1086- BIN_PATH ,
1087- resolve ( TEST_DIR , 'recursive-fork/index.ts' ) ,
1088- 'argv2' ,
1089- ] ,
1090- } ;
1091- expect ( JSON . parse ( generations [ 0 ] ) ) . toMatchObject ( expectation ) ;
1092- expectation . argv [ 0 ] = BIN_PATH_JS ;
1093- expect ( JSON . parse ( generations [ 1 ] ) ) . toMatchObject ( expectation ) ;
1094- expect ( JSON . parse ( generations [ 2 ] ) ) . toMatchObject ( expectation ) ;
1081+
1082+ function forkTest (
1083+ command : string ,
1084+ expectParentArgv0 : string ,
1085+ nodeFlag ?: string
1086+ ) {
1087+ test ( command , async ( t ) => {
1088+ const { err, stderr, stdout } = await exec (
1089+ `${ command } --skipIgnore ./recursive-fork/index.ts argv2`
1090+ ) ;
1091+ expect ( err ) . toBeNull ( ) ;
1092+ expect ( stderr ) . toBe ( '' ) ;
1093+ const generations = stdout . split ( '\n' ) ;
1094+ const expectation = {
1095+ execArgv : [ nodeFlag , BIN_PATH_JS , '--skipIgnore' ] . filter ( ( v ) => v ) ,
1096+ argv : [
1097+ // Note: argv[0] is *always* BIN_PATH_JS in child & grandchild
1098+ expectParentArgv0 ,
1099+ resolve ( TEST_DIR , 'recursive-fork/index.ts' ) ,
1100+ 'argv2' ,
1101+ ] ,
1102+ } ;
1103+ expect ( JSON . parse ( generations [ 0 ] ) ) . toMatchObject ( expectation ) ;
1104+ expectation . argv [ 0 ] = BIN_PATH_JS ;
1105+ expect ( JSON . parse ( generations [ 1 ] ) ) . toMatchObject ( expectation ) ;
1106+ expect ( JSON . parse ( generations [ 2 ] ) ) . toMatchObject ( expectation ) ;
1107+ } ) ;
1108+ }
10951109 } ) ;
10961110} ) ;
10971111
0 commit comments