Skip to content

Commit 01bed64

Browse files
MoLowtargos
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 12e54e3 commit 01bed64

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
@@ -318,7 +318,7 @@ class FileTest extends Test {
318318

319319
function runTestFile(path, filesWatcher, opts) {
320320
const watchMode = filesWatcher != null;
321-
const subtest = opts.root.createSubtest(FileTest, path, async (t) => {
321+
const subtest = opts.root.createSubtest(FileTest, path, { __proto__: null, signal: opts.signal }, async (t) => {
322322
const args = getRunArgs(path, opts);
323323
const stdio = ['pipe', 'pipe', 'pipe'];
324324
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
@@ -176,6 +176,17 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {
176176
});
177177

178178
describe('AbortSignal', () => {
179+
it('should accept a signal', async () => {
180+
const stream = run({ signal: AbortSignal.timeout(50), files: [
181+
fixtures.path('test-runner', 'never_ending_sync.js'),
182+
fixtures.path('test-runner', 'never_ending_async.js'),
183+
] });
184+
stream.on('test:fail', common.mustCall(2));
185+
stream.on('test:pass', common.mustNotCall());
186+
// eslint-disable-next-line no-unused-vars
187+
for await (const _ of stream);
188+
});
189+
179190
it('should stop watch mode when abortSignal aborts', async () => {
180191
const controller = new AbortController();
181192
const result = await run({

0 commit comments

Comments
 (0)