Skip to content

Commit

Permalink
arguments to test binaries
Browse files Browse the repository at this point in the history
  • Loading branch information
Zsolt Szalka committed Feb 2, 2024
1 parent e626ead commit 0a68b90
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/rust/src/executors/test/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@
"type": "boolean",
"default": false,
"description": "Build all test targets"
},
"-- --test-threads": {
"type": "number",
"minimum": 0,
"default": 0,
"description": "arguments following the two dashes (--) are passed to the test binaries, 0 disables option"
}
},
"required": []
Expand Down
14 changes: 14 additions & 0 deletions packages/rust/src/utils/build-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,21 @@ export function buildCommand(

args.push(baseCommand);

// flags after '-- ' should be passed to binaries after any other option
let argstobinaries = ['--'];

Check failure on line 18 in packages/rust/src/utils/build-command.ts

View workflow job for this annotation

GitHub Actions / checks

'argstobinaries' is never reassigned. Use 'const' instead
for (const [key, value] of Object.entries(options)) {
if (key === 'toolchain') {
continue;
}
if (key === '-- --test-threads' && value === 0) {
// -- --test-threads=0 comes from schema default to avoid setting thread number if not rquested
continue;
}
if (key.startsWith('-- ') ) {
// use '-- ' only once, save argument to append to the end of args
argstobinaries.push(key.substring(3), value);
continue;
}

if (typeof value === 'boolean') {
// false flags should not be added to the cargo args
Expand All @@ -36,6 +47,9 @@ export function buildCommand(
if (!args.includes("--package")) {
args.push("-p", context.projectName);
}
if (argstobinaries.length > 1) {
args.push(...argstobinaries);
}

return args;
}

0 comments on commit 0a68b90

Please sign in to comment.