GeezerVison is showing github.com — test_runner: fix infinite loop when files are undefined in test runner · nodejs/node@d5c9adf
File tree
Expand 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 +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -487,6 +487,9 @@ function run(options = kEmptyObject) { |
487 | 487 | } |
488 | 488 |
|
489 | 489 | const root = createTestTree({ __proto__: null, concurrency, timeout, signal }); |
| 490 | + if (process.env.NODE_TEST_CONTEXT !== undefined) { |
| 491 | + return root.reporter; |
| 492 | + } |
490 | 493 | let testFiles = files ?? createTestFileList(); |
491 | 494 |
|
492 | 495 | if (shard) { |
|
Collapse file
Copy file name to clipboardExpand all lines: test/parallel/test-runner-run.mjs +33Lines changed: 33 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -466,4 +466,37 @@ describe('require(\'node:test\').run', { concurrency: true }, () => { |
466 | 466 | })); |
467 | 467 | }); |
468 | 468 | }); |
| 469 | + |
| 470 | + it('should run with no files', async () => { |
| 471 | + const stream = run({ |
| 472 | + files: undefined |
| 473 | + }).compose(tap); |
| 474 | + stream.on('test:fail', common.mustNotCall()); |
| 475 | + stream.on('test:pass', common.mustNotCall()); |
| 476 | + |
| 477 | + // eslint-disable-next-line no-unused-vars |
| 478 | + for await (const _ of stream); |
| 479 | + }); |
| 480 | + |
| 481 | + it('should run with no files and use spec reporter', async () => { |
| 482 | + const stream = run({ |
| 483 | + files: undefined |
| 484 | + }).compose(spec); |
| 485 | + stream.on('test:fail', common.mustNotCall()); |
| 486 | + stream.on('test:pass', common.mustNotCall()); |
| 487 | + |
| 488 | + // eslint-disable-next-line no-unused-vars |
| 489 | + for await (const _ of stream); |
| 490 | + }); |
| 491 | + |
| 492 | + it('should run with no files and use dot reporter', async () => { |
| 493 | + const stream = run({ |
| 494 | + files: undefined |
| 495 | + }).compose(dot); |
| 496 | + stream.on('test:fail', common.mustNotCall()); |
| 497 | + stream.on('test:pass', common.mustNotCall()); |
| 498 | + |
| 499 | + // eslint-disable-next-line no-unused-vars |
| 500 | + for await (const _ of stream); |
| 501 | + }); |
469 | 502 | }); |