From e823475e704c378fb27a8f0820d0d8f3d1caa0d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannik=20Gl=C3=BCckert?= Date: Thu, 31 Oct 2024 20:02:39 +0100 Subject: [PATCH] make number of test parallelism configurable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jannik Glückert --- package.json | 6 ++++++ src/tests.ts | 12 +++++++++++- src/types.ts | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index ae297f1..2c92304 100644 --- a/package.json +++ b/package.json @@ -158,6 +158,12 @@ "default": {}, "description": "Specify the list of additional environment variables used for running tests." }, + "mesonbuild.testJobs": { + "type": "integer", + "default": -1, + "minimum": -1, + "description": "Specify the maximum number of tests executed in parallel. -1 for number of CPUs, 0 for unlimited." + }, "mesonbuild.benchmarkOptions": { "type": "array", "default": [ diff --git a/src/tests.ts b/src/tests.ts index 9b22186..f32b186 100644 --- a/src/tests.ts +++ b/src/tests.ts @@ -109,7 +109,17 @@ export async function testRunHandler( } const running_tests: Promise[] = []; - const max_running = os.cpus().length; + const max_running: number = (() => { + const jobs_config = extensionConfiguration("testJobs"); + switch (jobs_config) { + case -1: + return os.cpus().length; + case 0: + return Number.MAX_SAFE_INTEGER; + default: + return jobs_config; + } + })(); for (const test of parallelTests) { const running_test = dispatchTest(test).finally(() => { diff --git a/src/types.ts b/src/types.ts index ad7f559..41e572e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -18,6 +18,7 @@ export interface ExtensionConfiguration { setupOptions: string[]; testOptions: string[]; testEnvironment: { [key: string]: string }; + testJobs: number; benchmarkOptions: string[]; buildFolder: string; mesonPath: string;