|
1 | 1 | 'use strict';
|
2 | 2 | const {
|
3 | 3 | ArrayPrototypePush,
|
4 |
| - ArrayPrototypeReduce, |
5 | 4 | ArrayPrototypeShift,
|
6 | 5 | ArrayPrototypeUnshift,
|
7 | 6 | FunctionPrototype,
|
8 | 7 | Number,
|
9 |
| - PromiseResolve, |
10 | 8 | ReflectApply,
|
11 | 9 | SafeMap,
|
12 | 10 | PromiseRace,
|
13 | 11 | SafePromiseAll,
|
| 12 | + MathMax |
14 | 13 | } = primordials;
|
15 | 14 | const { AsyncResource } = require('async_hooks');
|
16 | 15 | const {
|
@@ -43,9 +42,7 @@ const noop = FunctionPrototype;
|
43 | 42 | const isTestRunner = getOptionValue('--test');
|
44 | 43 | const testOnlyFlag = !isTestRunner && getOptionValue('--test-only');
|
45 | 44 | // 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; |
49 | 46 |
|
50 | 47 | function testTimeout(promise, timeout) {
|
51 | 48 | if (timeout === kDefaultTimeout) {
|
@@ -139,6 +136,14 @@ class Test extends AsyncResource {
|
139 | 136 | this.concurrency = concurrency;
|
140 | 137 | }
|
141 | 138 |
|
| 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 | + |
142 | 147 | if (isUint32(timeout)) {
|
143 | 148 | this.timeout = timeout;
|
144 | 149 | }
|
@@ -508,14 +513,7 @@ class Suite extends Test {
|
508 | 513 | this.parent.activeSubtests++;
|
509 | 514 | this.startTime = hrtime();
|
510 | 515 | 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()); |
519 | 517 | this.pass();
|
520 | 518 | this.postRun();
|
521 | 519 | }
|
|
0 commit comments