@@ -13,7 +13,10 @@ skipIfSingleExecutableIsNotSupported();
13
13
14
14
const tmpdir = require ( '../common/tmpdir' ) ;
15
15
const { copyFileSync, writeFileSync, existsSync } = require ( 'fs' ) ;
16
- const { spawnSync } = require ( 'child_process' ) ;
16
+ const {
17
+ spawnSyncAndExit,
18
+ spawnSyncAndExitWithoutError
19
+ } = require ( '../common/child_process' ) ;
17
20
const assert = require ( 'assert' ) ;
18
21
19
22
const configFile = tmpdir . resolve ( 'sea-config.json' ) ;
@@ -32,16 +35,17 @@ const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'se
32
35
}
33
36
` ) ;
34
37
35
- const child = spawnSync (
38
+ spawnSyncAndExit (
36
39
process . execPath ,
37
40
[ '--experimental-sea-config' , 'sea-config.json' ] ,
38
41
{
39
42
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 \( \) /
40
48
} ) ;
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 \( \) / ) ;
45
49
}
46
50
47
51
{
@@ -65,24 +69,31 @@ const outputFile = tmpdir.resolve(process.platform === 'win32' ? 'sea.exe' : 'se
65
69
}
66
70
` ) ;
67
71
68
- let child = spawnSync (
72
+ spawnSyncAndExitWithoutError (
69
73
process . execPath ,
70
74
[ '--experimental-sea-config' , 'sea-config.json' ] ,
71
75
{
72
76
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 /
73
80
} ) ;
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 / ) ;
77
81
78
82
assert ( existsSync ( seaPrepBlob ) ) ;
79
83
80
84
copyFileSync ( process . execPath , outputFile ) ;
81
85
injectAndCodeSign ( outputFile , seaPrepBlob ) ;
82
86
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
+ ) ;
88
99
}
0 commit comments