@@ -13,7 +13,10 @@ skipIfSingleExecutableIsNotSupported();
1313
1414const tmpdir = require ( '../common/tmpdir' ) ;
1515const { copyFileSync, writeFileSync, existsSync } = require ( 'fs' ) ;
16- const { spawnSync } = require ( 'child_process' ) ;
16+ const {
17+ spawnSyncAndExit,
18+ spawnSyncAndExitWithoutError
19+ } = require ( '../common/child_process' ) ;
1720const assert = require ( 'assert' ) ;
1821
1922const configFile = tmpdir . resolve ( 'sea-config.json' ) ;
@@ -32,16 +35,17 @@ const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'se
3235 }
3336 ` ) ;
3437
35- const child = spawnSync (
38+ spawnSyncAndExit (
3639 process . execPath ,
3740 [ '--experimental-sea-config' , 'sea-config.json' ] ,
3841 {
3942 cwd : tmpdir . path
43+ } ,
44+ {
45+ status : 1 ,
46+ signal : null ,
47+ stderr : / s n a p s h o t \. j s d o e s n o t i n v o k e v 8 \. s t a r t u p S n a p s h o t \. s e t D e s e r i a l i z e M a i n F u n c t i o n \( \) /
4048 } ) ;
41-
42- assert . match (
43- child . stderr . toString ( ) ,
44- / s n a p s h o t \. j s d o e s n o t i n v o k e v 8 \. s t a r t u p S n a p s h o t \. s e t D e s e r i a l i z e M a i n F u n c t i o n \( \) / ) ;
4549}
4650
4751{
@@ -65,24 +69,31 @@ const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'se
6569 }
6670 ` ) ;
6771
68- let child = spawnSync (
72+ spawnSyncAndExitWithoutError (
6973 process . execPath ,
7074 [ '--experimental-sea-config' , 'sea-config.json' ] ,
7175 {
7276 cwd : tmpdir . path
77+ } ,
78+ {
79+ stderr : / S i n g l e e x e c u t a b l e a p p l i c a t i o n i s a n e x p e r i m e n t a l f e a t u r e /
7380 } ) ;
74- assert . match (
75- child . stderr . toString ( ) ,
76- / S i n g l e e x e c u t a b l e a p p l i c a t i o n i s a n e x p e r i m e n t a l f e a t u r e / ) ;
7781
7882 assert ( existsSync ( seaPrepBlob ) ) ;
7983
8084 copyFileSync ( process . execPath , outputFile ) ;
8185 injectAndCodeSign ( outputFile , seaPrepBlob ) ;
8286
83- child = spawnSync ( outputFile ) ;
84- assert . strictEqual ( child . stdout . toString ( ) . trim ( ) , 'Hello from snapshot' ) ;
85- assert . doesNotMatch (
86- child . stderr . toString ( ) ,
87- / S i n g l e e x e c u t a b l e a p p l i c a t i o n i s a n e x p e r i m e n t a l f e a t u r e / ) ;
87+ spawnSyncAndExitWithoutError (
88+ outputFile ,
89+ {
90+ trim : true ,
91+ stdout : 'Hello from snapshot' ,
92+ stderr ( output ) {
93+ assert . doesNotMatch (
94+ output ,
95+ / S i n g l e e x e c u t a b l e a p p l i c a t i o n i s a n e x p e r i m e n t a l f e a t u r e / ) ;
96+ }
97+ }
98+ ) ;
8899}
0 commit comments