77require ( '../common' ) ;
88
99const assert = require ( 'assert' ) ;
10- const { spawnSync } = require ( 'child_process' ) ;
1110const tmpdir = require ( '../common/tmpdir' ) ;
1211const fixtures = require ( '../common/fixtures' ) ;
13- const { expectSyncExitWithoutError } = require ( '../common/child_process' ) ;
12+ const { spawnSyncAndExitWithoutError } = require ( '../common/child_process' ) ;
1413const fs = require ( 'fs' ) ;
1514
1615const warningScript = fixtures . path ( 'snapshot' , 'warning.js' ) ;
@@ -20,48 +19,44 @@ const empty = fixtures.path('empty.js');
2019tmpdir . refresh ( ) ;
2120{
2221 console . log ( '\n# Check snapshot scripts that do not emit warnings.' ) ;
23- let child = spawnSync ( process . execPath , [
22+ spawnSyncAndExitWithoutError ( process . execPath , [
2423 '--snapshot-blob' ,
2524 blobPath ,
2625 '--build-snapshot' ,
2726 empty ,
2827 ] , {
2928 cwd : tmpdir . path
3029 } ) ;
31- expectSyncExitWithoutError ( child ) ;
3230 const stats = fs . statSync ( blobPath ) ;
3331 assert ( stats . isFile ( ) ) ;
3432
35- child = spawnSync ( process . execPath , [
33+ spawnSyncAndExitWithoutError ( process . execPath , [
3634 '--snapshot-blob' ,
3735 blobPath ,
3836 warningScript ,
3937 ] , {
4038 cwd : tmpdir . path
41- } ) ;
42- expectSyncExitWithoutError ( child , {
39+ } , {
4340 stderr ( output ) {
4441 const match = output . match ( / W a r n i n g : t e s t w a r n i n g / g) ;
4542 assert . strictEqual ( match . length , 1 ) ;
4643 return true ;
4744 }
4845 } ) ;
49-
5046}
5147
5248tmpdir . refresh ( ) ;
5349{
5450 console . log ( '\n# Check snapshot scripts that emit ' +
5551 'warnings and --trace-warnings hint.' ) ;
56- let child = spawnSync ( process . execPath , [
52+ spawnSyncAndExitWithoutError ( process . execPath , [
5753 '--snapshot-blob' ,
5854 blobPath ,
5955 '--build-snapshot' ,
6056 warningScript ,
6157 ] , {
6258 cwd : tmpdir . path
63- } ) ;
64- expectSyncExitWithoutError ( child , {
59+ } , {
6560 stderr ( output ) {
6661 let match = output . match ( / W a r n i n g : t e s t w a r n i n g / g) ;
6762 assert . strictEqual ( match . length , 1 ) ;
@@ -73,15 +68,13 @@ tmpdir.refresh();
7368 const stats = fs . statSync ( blobPath ) ;
7469 assert ( stats . isFile ( ) ) ;
7570
76- child = spawnSync ( process . execPath , [
71+ spawnSyncAndExitWithoutError ( process . execPath , [
7772 '--snapshot-blob' ,
7873 blobPath ,
7974 warningScript ,
8075 ] , {
8176 cwd : tmpdir . path
82- } ) ;
83-
84- expectSyncExitWithoutError ( child , {
77+ } , {
8578 stderr ( output ) {
8679 // Warnings should not be handled more than once.
8780 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();
9992 const warningFile1 = tmpdir . resolve ( 'warnings.txt' ) ;
10093 const warningFile2 = tmpdir . resolve ( 'warnings2.txt' ) ;
10194
102- let child = spawnSync ( process . execPath , [
95+ spawnSyncAndExitWithoutError ( process . execPath , [
10396 '--snapshot-blob' ,
10497 blobPath ,
10598 '--redirect-warnings' ,
@@ -108,9 +101,7 @@ tmpdir.refresh();
108101 warningScript ,
109102 ] , {
110103 cwd : tmpdir . path
111- } ) ;
112-
113- expectSyncExitWithoutError ( child , {
104+ } , {
114105 stderr ( output ) {
115106 assert . doesNotMatch ( output , / W a r n i n g : t e s t w a r n i n g / ) ;
116107 }
@@ -129,17 +120,15 @@ tmpdir.refresh();
129120 maxRetries : 3 , recursive : false , force : true
130121 } ) ;
131122
132- child = spawnSync ( process . execPath , [
123+ spawnSyncAndExitWithoutError ( process . execPath , [
133124 '--snapshot-blob' ,
134125 blobPath ,
135126 '--redirect-warnings' ,
136127 warningFile2 ,
137128 warningScript ,
138129 ] , {
139130 cwd : tmpdir . path
140- } ) ;
141-
142- expectSyncExitWithoutError ( child , {
131+ } , {
143132 stderr ( output ) {
144133 assert . doesNotMatch ( output , / W a r n i n g : t e s t w a r n i n g / ) ;
145134 return true ;
0 commit comments