Skip to content

Commit 80c40f8

Browse files
committed
test_runner: use exiting option instead of cli
1 parent ae30359 commit 80c40f8

File tree

4 files changed

+11
-25
lines changed

4 files changed

+11
-25
lines changed

doc/api/cli.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,14 +1108,6 @@ Starts the Node.js command line test runner. This flag cannot be combined with
11081108
`--check`, `--eval`, `--interactive`, or the inspector. See the documentation
11091109
on [running tests from the command line][] for more details.
11101110

1111-
### `--test-concurrency`
1112-
1113-
<!-- YAML
1114-
added: REPLACEME
1115-
-->
1116-
1117-
Configures the tests to run concurrently.
1118-
11191111
### `--test-only`
11201112

11211113
<!-- YAML

lib/internal/test_runner/test.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
'use strict';
22
const {
33
ArrayPrototypePush,
4-
ArrayPrototypeReduce,
54
ArrayPrototypeShift,
65
ArrayPrototypeUnshift,
76
FunctionPrototype,
87
Number,
9-
PromiseResolve,
108
ReflectApply,
119
SafeMap,
1210
PromiseRace,
1311
SafePromiseAll,
12+
MathMax
1413
} = primordials;
1514
const { AsyncResource } = require('async_hooks');
1615
const {
@@ -43,9 +42,7 @@ const noop = FunctionPrototype;
4342
const isTestRunner = getOptionValue('--test');
4443
const testOnlyFlag = !isTestRunner && getOptionValue('--test-only');
4544
// TODO(cjihrig): Use uv_available_parallelism() once it lands.
46-
const isConcurrent = getOptionValue('--test-concurrency');
47-
const rootConcurrency = isTestRunner && isConcurrent ? cpus().length - 1 : 1;
48-
const subTestConcurrency = isConcurrent;
45+
const rootConcurrency = isTestRunner ? MathMax(cpus().length - 1, 1) : 1;
4946

5047
function testTimeout(promise, timeout) {
5148
if (timeout === kDefaultTimeout) {
@@ -139,6 +136,14 @@ class Test extends AsyncResource {
139136
this.concurrency = concurrency;
140137
}
141138

139+
if (typeof concurrency === 'boolean') {
140+
if (isTestRunner) {
141+
this.concurrency = concurrency ? MathMax(cpus().length - 1, 1) : 1;
142+
} else {
143+
this.concurrency = concurrency ? Infinity : 1;
144+
}
145+
}
146+
142147
if (isUint32(timeout)) {
143148
this.timeout = timeout;
144149
}
@@ -508,14 +513,7 @@ class Suite extends Test {
508513
this.parent.activeSubtests++;
509514
this.startTime = hrtime();
510515
const subtests = this.skipped || this.error ? [] : this.subtests;
511-
if (subTestConcurrency) {
512-
await SafePromiseAll(subtests, (subtests) => subtests.start());
513-
} else {
514-
await testTimeout(ArrayPrototypeReduce(subtests, async (prev, subtest) => {
515-
await prev;
516-
await subtest.run();
517-
}, PromiseResolve()), this.timeout);
518-
}
516+
await SafePromiseAll(subtests, (subtests) => subtests.start());
519517
this.pass();
520518
this.postRun();
521519
}

src/node_options.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -525,9 +525,6 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
525525
AddOption("--test",
526526
"launch test runner on startup",
527527
&EnvironmentOptions::test_runner);
528-
AddOption("--test-concurrency",
529-
"tests defined within a file run in parallel",
530-
&EnvironmentOptions::test_concurrency);
531528
AddOption("--test-only",
532529
"run tests with 'only' option set",
533530
&EnvironmentOptions::test_only,

src/node_options.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ class EnvironmentOptions : public Options {
150150
std::string redirect_warnings;
151151
std::string diagnostic_dir;
152152
bool test_runner = false;
153-
bool test_concurrency = false;
154153
bool test_only = false;
155154
bool test_udp_no_try_send = false;
156155
bool throw_deprecation = false;

0 commit comments

Comments
 (0)