Skip to content

Commit 504f766

Browse files
committed
make number of test parallelism configurable
Signed-off-by: Jannik Glückert <jannik.glueckert@gmail.com>
1 parent b7176c9 commit 504f766

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@
158158
"default": {},
159159
"description": "Specify the list of additional environment variables used for running tests."
160160
},
161+
"mesonbuild.testJobs": {
162+
"type": "integer",
163+
"default": -1,
164+
"minimum": -1,
165+
"description": "Specify the maximum number of tests executed in parallel. -1 for number of CPUs, 0 for unlimited."
166+
},
161167
"mesonbuild.benchmarkOptions": {
162168
"type": "array",
163169
"default": [

src/tests.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,17 @@ export async function testRunHandler(
109109
}
110110

111111
const running_tests: Promise<void>[] = [];
112-
const max_running = os.cpus().length;
112+
const max_running: number = (() => {
113+
const jobs_config = extensionConfiguration("testJobs");
114+
switch (jobs_config) {
115+
case -1:
116+
return os.cpus().length;
117+
case 0:
118+
return Number.MAX_SAFE_INTEGER;
119+
default:
120+
return jobs_config;
121+
}
122+
})();
113123

114124
for (const test of parallelTests) {
115125
const running_test = dispatchTest(test).finally(() => {

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ export interface ExtensionConfiguration {
7272
setupOptions: string[];
7373
testOptions: string[];
7474
testEnvironment: { [key: string]: string };
75+
testJobs: number;
7576
benchmarkOptions: string[];
7677
buildFolder: string;
7778
mesonPath: string;

0 commit comments

Comments
 (0)