Skip to content

Commit 2c72ed8

Browse files
MoLowUlisesGascon
authored andcommitted
test_runner: pass abortSignal to test files
PR-URL: #50630 Fixes: #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

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

lib/internal/test_runner/runner.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ class FileTest extends Test {
361361

362362
function runTestFile(path, filesWatcher, opts) {
363363
const watchMode = filesWatcher != null;
364-
const subtest = opts.root.createSubtest(FileTest, path, async (t) => {
364+
const subtest = opts.root.createSubtest(FileTest, path, { __proto__: null, signal: opts.signal }, async (t) => {
365365
const args = getRunArgs(path, opts);
366366
const stdio = ['pipe', 'pipe', 'pipe'];
367367
const env = { __proto__: null, ...process.env, NODE_TEST_CONTEXT: 'child-v8' };

test/parallel/test-runner-run.mjs

+11
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+
const stream = 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+
for await (const _ of stream);
196+
});
197+
187198
it('should stop watch mode when abortSignal aborts', async () => {
188199
const controller = new AbortController();
189200
const result = await run({

0 commit comments

Comments
 (0)