@@ -204,12 +204,6 @@ const tests = [
204204const numtests = tests . length ;
205205
206206
207- let testsNotRan = tests . length ;
208-
209- process . on ( 'beforeExit' , ( ) =>
210- assert . strictEqual ( testsNotRan , 0 )
211- ) ;
212-
213207function cleanupTmpFile ( ) {
214208 try {
215209 // Write over the file, clearing any history
@@ -225,6 +219,8 @@ function cleanupTmpFile() {
225219fs . createReadStream ( historyFixturePath )
226220 . pipe ( fs . createWriteStream ( historyPath ) ) . on ( 'unpipe' , ( ) => runTest ( ) ) ;
227221
222+ const runTestWrap = common . mustCall ( runTest , numtests ) ;
223+
228224function runTest ( assertCleaned ) {
229225 const opts = tests . shift ( ) ;
230226 if ( ! opts ) return ; // All done
@@ -294,8 +290,7 @@ function runTest(assertCleaned) {
294290 try {
295291 // Ensure everything that we expected was output
296292 assert . strictEqual ( expected . length , 0 ) ;
297- testsNotRan -- ;
298- setImmediate ( runTest , cleaned ) ;
293+ setImmediate ( runTestWrap , cleaned ) ;
299294 } catch ( err ) {
300295 console . error ( `Failed test # ${ numtests - tests . length } ` ) ;
301296 throw err ;
0 commit comments