Skip to content

Commit 0bd9704

Browse files
cjihrigtargos
authored andcommitted
test_runner: use os.availableParallelism()
This commit addresses an existing TODO in the code by moving to the new os.availableParallelism() instead of os.cpus().length. PR-URL: #45969 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
1 parent dfa4444 commit 0bd9704

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/internal/test_runner/test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const {
5454
} = require('internal/validators');
5555
const { setTimeout } = require('timers/promises');
5656
const { TIMEOUT_MAX } = require('internal/timers');
57-
const { cpus } = require('os');
57+
const { availableParallelism } = require('os');
5858
const { bigint: hrtime } = process.hrtime;
5959
const kCallbackAndPromisePresent = 'callbackAndPromisePresent';
6060
const kCancelledByParent = 'cancelledByParent';
@@ -231,8 +231,8 @@ class Test extends AsyncResource {
231231

232232
case 'boolean':
233233
if (concurrency) {
234-
// TODO(cjihrig): Use uv_available_parallelism() once it lands.
235-
this.concurrency = parent === null ? MathMax(cpus().length - 1, 1) : Infinity;
234+
this.concurrency = parent === null ?
235+
MathMax(availableParallelism() - 1, 1) : Infinity;
236236
} else {
237237
this.concurrency = 1;
238238
}

0 commit comments

Comments
 (0)