test_runner: pass abortSignal to test files
PR-URL: https://github.com/nodejs/node/pull/50630 Fixes: https://github.com/nodejs/node/issues/50583 Reviewed-By: Debadree Chatterjee <debadree333@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
parent
3c5eb43cad
commit
3cce03a03f
@ -318,7 +318,7 @@ class FileTest extends Test {
|
|||||||
|
|
||||||
function runTestFile(path, filesWatcher, opts) {
|
function runTestFile(path, filesWatcher, opts) {
|
||||||
const watchMode = filesWatcher != null;
|
const watchMode = filesWatcher != null;
|
||||||
const subtest = opts.root.createSubtest(FileTest, path, async (t) => {
|
const subtest = opts.root.createSubtest(FileTest, path, { __proto__: null, signal: opts.signal }, async (t) => {
|
||||||
const args = getRunArgs(path, opts);
|
const args = getRunArgs(path, opts);
|
||||||
const stdio = ['pipe', 'pipe', 'pipe'];
|
const stdio = ['pipe', 'pipe', 'pipe'];
|
||||||
const env = { __proto__: null, ...process.env, NODE_TEST_CONTEXT: 'child-v8' };
|
const env = { __proto__: null, ...process.env, NODE_TEST_CONTEXT: 'child-v8' };
|
||||||
|
@ -176,6 +176,17 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('AbortSignal', () => {
|
describe('AbortSignal', () => {
|
||||||
|
it('should accept a signal', async () => {
|
||||||
|
const stream = run({ signal: AbortSignal.timeout(50), files: [
|
||||||
|
fixtures.path('test-runner', 'never_ending_sync.js'),
|
||||||
|
fixtures.path('test-runner', 'never_ending_async.js'),
|
||||||
|
] });
|
||||||
|
stream.on('test:fail', common.mustCall(2));
|
||||||
|
stream.on('test:pass', common.mustNotCall());
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
for await (const _ of stream);
|
||||||
|
});
|
||||||
|
|
||||||
it('should stop watch mode when abortSignal aborts', async () => {
|
it('should stop watch mode when abortSignal aborts', async () => {
|
||||||
const controller = new AbortController();
|
const controller = new AbortController();
|
||||||
const result = await run({
|
const result = await run({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user