GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test_runner,test: fix flaky test-runner-cli-concurrency.js · nodejs/node@64ef108

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/main
    • test_runner.js
  • test/parallel
    • test-runner-cli-concurrency.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/internal/main/test_runner.js‎

Copy file name to clipboardExpand all lines: lib/internal/main/test_runner.js
+12-2Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ const {
1818
RegExpPrototypeExec,
1919
StringPrototypeSplit,
2020
} = primordials;
21+
let debug = require('internal/util/debuglog').debuglog('test_runner', (fn) => {
22+
debug = fn;
23+
});
2124

2225
prepareMainThreadExecution(false);
2326
markBootstrapComplete();
@@ -57,8 +60,15 @@ if (shardOption) {
5760
};
5861
}
5962

60-
run({ concurrency, inspectPort, watch: getOptionValue('--watch'), setup: setupTestReporters, shard })
61-
.on('test:fail', (data) => {
63+
const options = {
64+
concurrency,
65+
inspectPort,
66+
watch: getOptionValue('--watch'),
67+
setup: setupTestReporters,
68+
shard,
69+
};
70+
debug('test runner configuration:', options);
71+
run(options).on('test:fail', (data) => {
6272
if (data.todo === undefined || data.todo === false) {
6373
process.exitCode = kGenericUserError;
6474
}
Collapse file

‎test/parallel/test-runner-cli-concurrency.js‎

Copy file name to clipboard
+18-37Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,26 @@
11
'use strict';
2-
const common = require('../common');
3-
const tmpdir = require('../common/tmpdir');
4-
const { deepStrictEqual, strictEqual } = require('node:assert');
2+
require('../common');
3+
const fixtures = require('../common/fixtures');
4+
const assert = require('node:assert');
55
const { spawnSync } = require('node:child_process');
6-
const { readdirSync, writeFileSync } = require('node:fs');
7-
const { join } = require('node:path');
8-
const { beforeEach, test } = require('node:test');
6+
const { test } = require('node:test');
7+
const cwd = fixtures.path('test-runner', 'default-behavior');
8+
const env = { ...process.env, 'NODE_DEBUG': 'test_runner' };
99

10-
function createTestFile(name) {
11-
writeFileSync(join(tmpdir.path, name), `
12-
const fs = require('node:fs');
13-
14-
fs.unlinkSync(__filename);
15-
setTimeout(() => {}, 1_000_000_000);
16-
`);
17-
}
18-
19-
beforeEach(() => {
20-
tmpdir.refresh();
21-
createTestFile('test-1.js');
22-
createTestFile('test-2.js');
10+
test('default concurrency', async () => {
11+
const args = ['--test'];
12+
const cp = spawnSync(process.execPath, args, { cwd, env });
13+
assert.match(cp.stderr.toString(), /concurrency: true,/);
2314
});
2415

25-
test('concurrency of one', () => {
26-
const cp = spawnSync(process.execPath, ['--test', '--test-concurrency=1'], {
27-
cwd: tmpdir.path,
28-
timeout: common.platformTimeout(1000),
29-
});
30-
31-
strictEqual(cp.stderr.toString(), '');
32-
strictEqual(cp.error.code, 'ETIMEDOUT');
33-
deepStrictEqual(readdirSync(tmpdir.path), ['test-2.js']);
16+
test('concurrency of one', async () => {
17+
const args = ['--test', '--test-concurrency=1'];
18+
const cp = spawnSync(process.execPath, args, { cwd, env });
19+
assert.match(cp.stderr.toString(), /concurrency: 1,/);
3420
});
3521

36-
test('concurrency of two', () => {
37-
const cp = spawnSync(process.execPath, ['--test', '--test-concurrency=2'], {
38-
cwd: tmpdir.path,
39-
timeout: common.platformTimeout(1000),
40-
});
41-
42-
strictEqual(cp.stderr.toString(), '');
43-
strictEqual(cp.error.code, 'ETIMEDOUT');
44-
deepStrictEqual(readdirSync(tmpdir.path), []);
22+
test('concurrency of two', async () => {
23+
const args = ['--test', '--test-concurrency=2'];
24+
const cp = spawnSync(process.execPath, args, { cwd, env });
25+
assert.match(cp.stderr.toString(), /concurrency: 2,/);
4526
});

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.