Skip to content

Commit

Permalink
test_runner: integrate abort signal handling in test tree creation
Browse files Browse the repository at this point in the history
  • Loading branch information
pmarchini committed Jan 11, 2025
1 parent 1d68db4 commit e691cd6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 13 deletions.
5 changes: 4 additions & 1 deletion lib/internal/test_runner/harness.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const {
shouldColorizeTestFiles,
} = require('internal/test_runner/utils');
const { queueMicrotask } = require('internal/process/task_queues');
const { AbortController } = require('internal/abort_controller');
const { AbortController, AbortSignal } = require('internal/abort_controller');
const { bigint: hrtime } = process.hrtime;
const resolvedPromise = PromiseResolve();
const testResources = new SafeMap();
Expand Down Expand Up @@ -87,6 +87,9 @@ function createTestTree(rootTestOptions, globalOptions) {
globalRoot = new Test({
__proto__: null,
...rootTestOptions,
signal: rootTestOptions.signal ?
AbortSignal.any([rootTestOptions.signal, harness.abortController.signal]) :
harness.abortController.signal,
harness,
name: '<root>',
});
Expand Down
13 changes: 1 addition & 12 deletions lib/internal/test_runner/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ const {
} = require('internal/test_runner/utils');
const { Glob } = require('internal/fs/glob');
const { once } = require('events');
const { AbortSignal } = require('internal/abort_controller');
const {
triggerUncaughtException,
exitCodes: { kGenericUserError },
Expand Down Expand Up @@ -231,11 +230,6 @@ class FileTest extends Test {
item.data.details.error = deserializeError(item.data.details.error);
}
if (item.type === 'test:bail') {
// <-- here we need to stop all the pending test files (aka subprocesses)
// To be replaced, just for poc
// this.root.harness.testsProcesses.forEach((child) => {
// child.kill();
// });
this.root.harness.abortTestTree();
this.root.bailed = true;
this.bailed = true;
Expand Down Expand Up @@ -407,12 +401,7 @@ function runTestFile(path, filesWatcher, opts) {
process.execPath, args,
{
__proto__: null,
signal: AbortSignal.any(
[
t.signal,
opts.root.harness.abortController.signal,
],
),
signal: t.signal,
encoding: 'utf8',
env,
stdio,
Expand Down

0 comments on commit e691cd6

Please sign in to comment.