Skip to content

Commit 2c72ed8

Browse files
MoLowUlisesGascon
authored andcommitted
test_runner: pass abortSignal to test files
PR-URL: #50630Fixes: #50583 Reviewed-By: Debadree Chatterjee <debadree333@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent 2589a5a commit 2c72ed8

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

‎lib/internal/test_runner/runner.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ class FileTest extends Test {
361361

362362
functionrunTestFile(path,filesWatcher,opts){
363363
constwatchMode=filesWatcher!=null;
364-
constsubtest=opts.root.createSubtest(FileTest,path,async(t)=>{
364+
constsubtest=opts.root.createSubtest(FileTest,path,{__proto__: null,signal: opts.signal},async(t)=>{
365365
constargs=getRunArgs(path,opts);
366366
conststdio=['pipe','pipe','pipe'];
367367
constenv={__proto__: null, ...process.env,NODE_TEST_CONTEXT: 'child-v8'};

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,17 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {
184184
});
185185

186186
describe('AbortSignal',()=>{
187+
it('should accept a signal',async()=>{
188+
conststream=run({signal: AbortSignal.timeout(50),files: [
189+
fixtures.path('test-runner','never_ending_sync.js'),
190+
fixtures.path('test-runner','never_ending_async.js'),
191+
]});
192+
stream.on('test:fail',common.mustCall(2));
193+
stream.on('test:pass',common.mustNotCall());
194+
// eslint-disable-next-line no-unused-vars
195+
forawait(const_ofstream);
196+
});
197+
187198
it('should stop watch mode when abortSignal aborts',async()=>{
188199
constcontroller=newAbortController();
189200
constresult=awaitrun({

0 commit comments

Comments
 (0)