@@ -193,12 +193,6 @@ const tests = [
193
193
const numtests = tests . length ;
194
194
195
195
196
- let testsNotRan = tests . length ;
197
-
198
- process . on ( 'beforeExit' , ( ) =>
199
- assert . strictEqual ( testsNotRan , 0 )
200
- ) ;
201
-
202
196
function cleanupTmpFile ( ) {
203
197
try {
204
198
// Write over the file, clearing any history
@@ -214,6 +208,8 @@ function cleanupTmpFile() {
214
208
fs . createReadStream ( historyFixturePath )
215
209
. pipe ( fs . createWriteStream ( historyPath ) ) . on ( 'unpipe' , ( ) => runTest ( ) ) ;
216
210
211
+ const runTestWrap = common . mustCall ( runTest , numtests ) ;
212
+
217
213
function runTest ( assertCleaned ) {
218
214
const opts = tests . shift ( ) ;
219
215
if ( ! opts ) return ; // All done
@@ -283,8 +279,7 @@ function runTest(assertCleaned) {
283
279
try {
284
280
// Ensure everything that we expected was output
285
281
assert . strictEqual ( expected . length , 0 ) ;
286
- testsNotRan -- ;
287
- setImmediate ( runTest , cleaned ) ;
282
+ setImmediate ( runTestWrap , cleaned ) ;
288
283
} catch ( err ) {
289
284
console . error ( `Failed test # ${ numtests - tests . length } ` ) ;
290
285
throw err ;
0 commit comments