Skip to content

Commit

Permalink
make number of test parallelism configurable
Browse files Browse the repository at this point in the history
Signed-off-by: Jannik Glückert <[email protected]>
  • Loading branch information
Jannik2099 committed Oct 31, 2024
1 parent d1e27d5 commit e823475
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
12 changes: 11 additions & 1 deletion src/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,17 @@ export async function testRunHandler(
}

const running_tests: Promise<void>[] = [];
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(() => {
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface ExtensionConfiguration {
setupOptions: string[];
testOptions: string[];
testEnvironment: { [key: string]: string };
testJobs: number;
benchmarkOptions: string[];
buildFolder: string;
mesonPath: string;
Expand Down

0 comments on commit e823475

Please sign in to comment.