@@ -204,12 +204,6 @@ const tests = [
204
204
const numtests = tests . length ;
205
205
206
206
207
- let testsNotRan = tests . length ;
208
-
209
- process . on ( 'beforeExit' , ( ) =>
210
- assert . strictEqual ( testsNotRan , 0 )
211
- ) ;
212
-
213
207
function cleanupTmpFile ( ) {
214
208
try {
215
209
// Write over the file, clearing any history
@@ -225,6 +219,8 @@ function cleanupTmpFile() {
225
219
fs . createReadStream ( historyFixturePath )
226
220
. pipe ( fs . createWriteStream ( historyPath ) ) . on ( 'unpipe' , ( ) => runTest ( ) ) ;
227
221
222
+ const runTestWrap = common . mustCall ( runTest , numtests ) ;
223
+
228
224
function runTest ( assertCleaned ) {
229
225
const opts = tests . shift ( ) ;
230
226
if ( ! opts ) return ; // All done
@@ -294,8 +290,7 @@ function runTest(assertCleaned) {
294
290
try {
295
291
// Ensure everything that we expected was output
296
292
assert . strictEqual ( expected . length , 0 ) ;
297
- testsNotRan -- ;
298
- setImmediate ( runTest , cleaned ) ;
293
+ setImmediate ( runTestWrap , cleaned ) ;
299
294
} catch ( err ) {
300
295
console . error ( `Failed test # ${ numtests - tests . length } ` ) ;
301
296
throw err ;
0 commit comments