Skip to content

Commit d70915c

Browse files
committed
make number of test parallelism configurable
Signed-off-by: Jannik Glückert <[email protected]>
1 parent 1176306 commit d70915c

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

Diff for: package.json

+6
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": [

Diff for: src/tests.ts

+11-1
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(() => {

Diff for: src/types.ts

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface ExtensionConfiguration {
1818
setupOptions: string[];
1919
testOptions: string[];
2020
testEnvironment: { [key: string]: string };
21+
testJobs: number;
2122
benchmarkOptions: string[];
2223
buildFolder: string;
2324
mesonPath: string;

0 commit comments

Comments
 (0)