7
7
require ( '../common' ) ;
8
8
9
9
const assert = require ( 'assert' ) ;
10
- const { spawnSync } = require ( 'child_process' ) ;
11
10
const tmpdir = require ( '../common/tmpdir' ) ;
12
11
const fixtures = require ( '../common/fixtures' ) ;
13
- const { expectSyncExitWithoutError } = require ( '../common/child_process' ) ;
12
+ const { spawnSyncAndExitWithoutError } = require ( '../common/child_process' ) ;
14
13
const fs = require ( 'fs' ) ;
15
14
16
15
const warningScript = fixtures . path ( 'snapshot' , 'warning.js' ) ;
@@ -20,48 +19,44 @@ const empty = fixtures.path('empty.js');
20
19
tmpdir . refresh ( ) ;
21
20
{
22
21
console . log ( '\n# Check snapshot scripts that do not emit warnings.' ) ;
23
- let child = spawnSync ( process . execPath , [
22
+ spawnSyncAndExitWithoutError ( process . execPath , [
24
23
'--snapshot-blob' ,
25
24
blobPath ,
26
25
'--build-snapshot' ,
27
26
empty ,
28
27
] , {
29
28
cwd : tmpdir . path
30
29
} ) ;
31
- expectSyncExitWithoutError ( child ) ;
32
30
const stats = fs . statSync ( blobPath ) ;
33
31
assert ( stats . isFile ( ) ) ;
34
32
35
- child = spawnSync ( process . execPath , [
33
+ spawnSyncAndExitWithoutError ( process . execPath , [
36
34
'--snapshot-blob' ,
37
35
blobPath ,
38
36
warningScript ,
39
37
] , {
40
38
cwd : tmpdir . path
41
- } ) ;
42
- expectSyncExitWithoutError ( child , {
39
+ } , {
43
40
stderr ( output ) {
44
41
const match = output . match ( / W a r n i n g : t e s t w a r n i n g / g) ;
45
42
assert . strictEqual ( match . length , 1 ) ;
46
43
return true ;
47
44
}
48
45
} ) ;
49
-
50
46
}
51
47
52
48
tmpdir . refresh ( ) ;
53
49
{
54
50
console . log ( '\n# Check snapshot scripts that emit ' +
55
51
'warnings and --trace-warnings hint.' ) ;
56
- let child = spawnSync ( process . execPath , [
52
+ spawnSyncAndExitWithoutError ( process . execPath , [
57
53
'--snapshot-blob' ,
58
54
blobPath ,
59
55
'--build-snapshot' ,
60
56
warningScript ,
61
57
] , {
62
58
cwd : tmpdir . path
63
- } ) ;
64
- expectSyncExitWithoutError ( child , {
59
+ } , {
65
60
stderr ( output ) {
66
61
let match = output . match ( / W a r n i n g : t e s t w a r n i n g / g) ;
67
62
assert . strictEqual ( match . length , 1 ) ;
@@ -73,15 +68,13 @@ tmpdir.refresh();
73
68
const stats = fs . statSync ( blobPath ) ;
74
69
assert ( stats . isFile ( ) ) ;
75
70
76
- child = spawnSync ( process . execPath , [
71
+ spawnSyncAndExitWithoutError ( process . execPath , [
77
72
'--snapshot-blob' ,
78
73
blobPath ,
79
74
warningScript ,
80
75
] , {
81
76
cwd : tmpdir . path
82
- } ) ;
83
-
84
- expectSyncExitWithoutError ( child , {
77
+ } , {
85
78
stderr ( output ) {
86
79
// Warnings should not be handled more than once.
87
80
let match = output . match ( / W a r n i n g : t e s t w a r n i n g / g) ;
@@ -99,7 +92,7 @@ tmpdir.refresh();
99
92
const warningFile1 = tmpdir . resolve ( 'warnings.txt' ) ;
100
93
const warningFile2 = tmpdir . resolve ( 'warnings2.txt' ) ;
101
94
102
- let child = spawnSync ( process . execPath , [
95
+ spawnSyncAndExitWithoutError ( process . execPath , [
103
96
'--snapshot-blob' ,
104
97
blobPath ,
105
98
'--redirect-warnings' ,
@@ -108,9 +101,7 @@ tmpdir.refresh();
108
101
warningScript ,
109
102
] , {
110
103
cwd : tmpdir . path
111
- } ) ;
112
-
113
- expectSyncExitWithoutError ( child , {
104
+ } , {
114
105
stderr ( output ) {
115
106
assert . doesNotMatch ( output , / W a r n i n g : t e s t w a r n i n g / ) ;
116
107
}
@@ -129,17 +120,15 @@ tmpdir.refresh();
129
120
maxRetries : 3 , recursive : false , force : true
130
121
} ) ;
131
122
132
- child = spawnSync ( process . execPath , [
123
+ spawnSyncAndExitWithoutError ( process . execPath , [
133
124
'--snapshot-blob' ,
134
125
blobPath ,
135
126
'--redirect-warnings' ,
136
127
warningFile2 ,
137
128
warningScript ,
138
129
] , {
139
130
cwd : tmpdir . path
140
- } ) ;
141
-
142
- expectSyncExitWithoutError ( child , {
131
+ } , {
143
132
stderr ( output ) {
144
133
assert . doesNotMatch ( output , / W a r n i n g : t e s t w a r n i n g / ) ;
145
134
return true ;
0 commit comments