Skip to content

Commit b8f0ea6

Browse files
pulkit-30richardlau
authored andcommitted
test_runner: fix infinite loop when files are undefined in test runner
PR-URL: #51047Fixes: #48823 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 03b19cb commit b8f0ea6

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

‎lib/internal/test_runner/runner.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,9 @@ function run(options){
531531
}
532532

533533
constroot=createTestTree({__proto__: null, concurrency, timeout, signal });
534+
if(process.env.NODE_TEST_CONTEXT!==undefined){
535+
returnroot.reporter;
536+
}
534537
lettestFiles=files??createTestFileList();
535538

536539
if(shard){

‎test/parallel/test-runner-run.mjs‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,4 +458,37 @@ describe('require(\'node:test\').run',{concurrency: true }, () =>{
458458
assert.deepStrictEqual(executedTestFiles.sort(),[...shardsTestsFiles].sort());
459459
});
460460
});
461+
462+
it('should run with no files',async()=>{
463+
conststream=run({
464+
files: undefined
465+
}).compose(tap);
466+
stream.on('test:fail',common.mustNotCall());
467+
stream.on('test:pass',common.mustNotCall());
468+
469+
// eslint-disable-next-line no-unused-vars
470+
forawait(const_ofstream);
471+
});
472+
473+
it('should run with no files and use spec reporter',async()=>{
474+
conststream=run({
475+
files: undefined
476+
}).compose(spec);
477+
stream.on('test:fail',common.mustNotCall());
478+
stream.on('test:pass',common.mustNotCall());
479+
480+
// eslint-disable-next-line no-unused-vars
481+
forawait(const_ofstream);
482+
});
483+
484+
it('should run with no files and use dot reporter',async()=>{
485+
conststream=run({
486+
files: undefined
487+
}).compose(dot);
488+
stream.on('test:fail',common.mustNotCall());
489+
stream.on('test:pass',common.mustNotCall());
490+
491+
// eslint-disable-next-line no-unused-vars
492+
forawait(const_ofstream);
493+
});
461494
});

0 commit comments

Comments
(0)