Skip to content

Commit 6830bdd

Browse files
edoardopirovanoaeisenberg
authored andcommitted
Add option to pass additional arguments when running tests
1 parent e316dec commit 6830bdd

4 files changed

Lines changed: 15 additions & 3 deletions

File tree

extensions/ql-vscode/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Allow using raw LGTM project slugs for fetching LGTM databases. [#769](https://github.com/github/vscode-codeql/pull/769)
88
- Better error messages when BQRS interpretation fails to produce SARIF. [#770](https://github.com/github/vscode-codeql/pull/770)
99
- Implement sorting of the query history view by name, date, and results count. [#777](https://github.com/github/vscode-codeql/pull/777)
10+
- Add a configuration option to pass additional arguments to the CLI when running tests. [#785](https://github.com/github/vscode-codeql/pull/785)
1011

1112
## 1.4.3 - 22 February 2021
1213

extensions/ql-vscode/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,12 @@
182182
"default": "%q on %d - %s, %r result count [%t]",
183183
"description": "Default string for how to label query history items. %t is the time of the query, %q is the query name, %d is the database name, %r is the number of results, and %s is a status string."
184184
},
185+
"codeQL.runningTests.additionalTestArguments": {
186+
"scope": "machine",
187+
"type": "array",
188+
"default": [],
189+
"markdownDescription": "Additional command line arguments to pass to the CLI when [running tests](https://codeql.github.com/docs/codeql-cli/manual/test-run/). This setting should be an array of strings, each containing an argument to be passed."
190+
},
185191
"codeQL.runningTests.numberOfThreads": {
186192
"scope": "window",
187193
"type": "integer",

extensions/ql-vscode/src/cli.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,12 +509,12 @@ export class CodeQLCliServer implements Disposable {
509509
testPaths: string[], workspaces: string[], options: TestRunOptions
510510
): AsyncGenerator<TestCompleted, void, unknown> {
511511

512-
const subcommandArgs = [
512+
const subcommandArgs = this.cliConfig.additionalTestArguments.concat([
513513
'--additional-packs', workspaces.join(path.delimiter),
514514
'--threads',
515515
this.cliConfig.numberTestThreads.toString(),
516516
...testPaths
517-
];
517+
]);
518518

519519
for await (const event of await this.runAsyncCodeQlCliCommand<TestCompleted>(['test', 'run'],
520520
subcommandArgs, 'Run CodeQL Tests', options.cancellationToken, options.logger)) {

extensions/ql-vscode/src/config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ const DEBUG_SETTING = new Setting('debug', RUNNING_QUERIES_SETTING);
8181
const RUNNING_TESTS_SETTING = new Setting('runningTests', ROOT_SETTING);
8282
const RESULTS_DISPLAY_SETTING = new Setting('resultsDisplay', ROOT_SETTING);
8383

84+
export const ADDITIONAL_TEST_ARGUMENTS_SETTING = new Setting('additionalTestArguments', RUNNING_TESTS_SETTING);
8485
export const NUMBER_OF_TEST_THREADS_SETTING = new Setting('numberOfThreads', RUNNING_TESTS_SETTING);
8586
export const MAX_QUERIES = new Setting('maxQueries', RUNNING_QUERIES_SETTING);
8687
export const AUTOSAVE_SETTING = new Setting('autoSave', RUNNING_QUERIES_SETTING);
@@ -108,9 +109,10 @@ export interface QueryHistoryConfig {
108109
onDidChangeConfiguration: Event<void>;
109110
}
110111

111-
const CLI_SETTINGS = [NUMBER_OF_TEST_THREADS_SETTING, NUMBER_OF_THREADS_SETTING];
112+
const CLI_SETTINGS = [ADDITIONAL_TEST_ARGUMENTS_SETTING, NUMBER_OF_TEST_THREADS_SETTING, NUMBER_OF_THREADS_SETTING];
112113

113114
export interface CliConfig {
115+
additionalTestArguments: string[];
114116
numberTestThreads: number;
115117
numberThreads: number;
116118
onDidChangeConfiguration?: Event<void>;
@@ -243,6 +245,9 @@ export class QueryHistoryConfigListener extends ConfigListener implements QueryH
243245
}
244246

245247
export class CliConfigListener extends ConfigListener implements CliConfig {
248+
public get additionalTestArguments(): string[] {
249+
return ADDITIONAL_TEST_ARGUMENTS_SETTING.getValue();
250+
}
246251

247252
public get numberTestThreads(): number {
248253
return NUMBER_OF_TEST_THREADS_SETTING.getValue();

0 commit comments

Comments
 (0)