GeezerVison is showing github.com — test_runner: pass abortSignal to test files · nodejs/node@2c72ed8
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/internal/test_runner/runner.js +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -361,7 +361,7 @@ class FileTest extends Test { | 361 | 361 |
| 362 | 362 | function runTestFile(path, filesWatcher, opts) { | 363 | 363 | 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) => { | 365 | 365 | const args = getRunArgs(path, opts); | 366 | 366 | const stdio = ['pipe', 'pipe', 'pipe']; | 367 | 367 | const env = { __proto__: null, ...process.env, NODE_TEST_CONTEXT: 'child-v8' }; | |
Collapse file Copy file name to clipboardExpand all lines: test/parallel/test-runner-run.mjs +11Lines changed: 11 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -184,6 +184,17 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { | 184 | 184 | }); | 185 | 185 |
| 186 | 186 | 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 | + | 187 | 198 | it('should stop watch mode when abortSignal aborts', async () => { | 188 | 199 | const controller = new AbortController(); | 189 | 200 | const result = await run({ | |
|