Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8048e05

Browse filesBrowse files
committed
test: fix skipping behavior for test-runner-run-files-undefined
PR-URL: #62026 Reviewed-By: Jacob Smith <jacob@frende.me> Reviewed-By: Anna Henningsen <anna@addaleax.net>
1 parent cc46204 commit 8048e05
Copy full SHA for 8048e05

1 file changed

+25-55Lines changed: 25 additions & 55 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file
+25-55Lines changed: 25 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,31 @@
1-
import * as common from '../common/index.mjs';
1+
import '../common/index.mjs';
22
import tmpdir from '../common/tmpdir.js';
3-
import { describe, it, run, beforeEach } from 'node:test';
4-
import { dot, spec, tap } from 'node:test/reporters';
5-
import { fork } from 'node:child_process';
6-
import assert from 'node:assert';
7-
8-
if (common.hasCrypto) {
9-
console.log('1..0 # Skipped: no crypto');
10-
process.exit(0);
11-
}
12-
13-
if (process.env.CHILD === 'true') {
14-
describe('require(\'node:test\').run with no files', { concurrency: true }, () => {
15-
beforeEach(() => {
16-
tmpdir.refresh();
17-
process.chdir(tmpdir.path);
3+
import { spawnSyncAndExitWithoutError } from '../common/child_process.js';
4+
5+
async function runTests(run, reporters) {
6+
for (const reporterName of Object.keys(reporters)) {
7+
if (reporterName === 'default') continue;
8+
console.log({ reporterName });
9+
10+
const stream = run({
11+
files: undefined
12+
}).compose(reporters[reporterName]);
13+
stream.on('test:fail', () => {
14+
throw new Error('Received test:fail with ' + reporterName);
1815
});
19-
20-
it('should neither pass or fail', async () => {
21-
const stream = run({
22-
files: undefined
23-
}).compose(tap);
24-
stream.on('test:fail', common.mustNotCall());
25-
stream.on('test:pass', common.mustNotCall());
26-
27-
// eslint-disable-next-line no-unused-vars
28-
for await (const _ of stream);
16+
stream.on('test:pass', () => {
17+
throw new Error('Received test:pass with ' + reporterName);
2918
});
3019

31-
it('can use the spec reporter', async () => {
32-
const stream = run({
33-
files: undefined
34-
}).compose(spec);
35-
stream.on('test:fail', common.mustNotCall());
36-
stream.on('test:pass', common.mustNotCall());
37-
38-
// eslint-disable-next-line no-unused-vars
39-
for await (const _ of stream);
40-
});
20+
// eslint-disable-next-line no-unused-vars
21+
for await (const _ of stream);
22+
}
23+
}
4124

42-
it('can use the dot reporter', async () => {
43-
const stream = run({
44-
files: undefined
45-
}).compose(dot);
46-
stream.on('test:fail', common.mustNotCall());
47-
stream.on('test:pass', common.mustNotCall());
25+
tmpdir.refresh();
26+
spawnSyncAndExitWithoutError(process.execPath, ['--input-type=module', '-e', `
27+
import { run } from 'node:test';
28+
import * as reporters from 'node:test/reporters';
4829
49-
// eslint-disable-next-line no-unused-vars
50-
for await (const _ of stream);
51-
});
52-
});
53-
} else if (common.isAIX) {
54-
console.log('1..0 # Skipped: test runner without specifying files fails on AIX');
55-
} else {
56-
fork(import.meta.filename, [], {
57-
env: { CHILD: 'true' }
58-
}).on('exit', common.mustCall((code) => {
59-
assert.strictEqual(code, 0);
60-
}));
61-
}
30+
await (${runTests})(run, reporters);
31+
`], { cwd: tmpdir.path });

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.