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 1b14433..805c990 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;