diff --git a/extensions/ql-vscode/CHANGELOG.md b/extensions/ql-vscode/CHANGELOG.md index b9378fe287d..e7c655fc385 100644 --- a/extensions/ql-vscode/CHANGELOG.md +++ b/extensions/ql-vscode/CHANGELOG.md @@ -7,6 +7,7 @@ - Allow using raw LGTM project slugs for fetching LGTM databases. [#769](https://github.com/github/vscode-codeql/pull/769) - Better error messages when BQRS interpretation fails to produce SARIF. [#770](https://github.com/github/vscode-codeql/pull/770) - Implement sorting of the query history view by name, date, and results count. [#777](https://github.com/github/vscode-codeql/pull/777) +- Add a configuration option to pass additional arguments to the CLI when running tests. [#785](https://github.com/github/vscode-codeql/pull/785) ## 1.4.3 - 22 February 2021 diff --git a/extensions/ql-vscode/package.json b/extensions/ql-vscode/package.json index 8b6a783f3a8..5c765dd3576 100644 --- a/extensions/ql-vscode/package.json +++ b/extensions/ql-vscode/package.json @@ -182,6 +182,12 @@ "default": "%q on %d - %s, %r result count [%t]", "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." }, + "codeQL.runningTests.additionalTestArguments": { + "scope": "machine", + "type": "array", + "default": [], + "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." + }, "codeQL.runningTests.numberOfThreads": { "scope": "window", "type": "integer", diff --git a/extensions/ql-vscode/src/cli.ts b/extensions/ql-vscode/src/cli.ts index e4548555ad1..947a229828f 100644 --- a/extensions/ql-vscode/src/cli.ts +++ b/extensions/ql-vscode/src/cli.ts @@ -509,12 +509,12 @@ export class CodeQLCliServer implements Disposable { testPaths: string[], workspaces: string[], options: TestRunOptions ): AsyncGenerator { - const subcommandArgs = [ + const subcommandArgs = this.cliConfig.additionalTestArguments.concat([ '--additional-packs', workspaces.join(path.delimiter), '--threads', this.cliConfig.numberTestThreads.toString(), ...testPaths - ]; + ]); for await (const event of await this.runAsyncCodeQlCliCommand(['test', 'run'], subcommandArgs, 'Run CodeQL Tests', options.cancellationToken, options.logger)) { diff --git a/extensions/ql-vscode/src/config.ts b/extensions/ql-vscode/src/config.ts index 885bf56bc6b..598c3f6f84e 100644 --- a/extensions/ql-vscode/src/config.ts +++ b/extensions/ql-vscode/src/config.ts @@ -81,6 +81,7 @@ const DEBUG_SETTING = new Setting('debug', RUNNING_QUERIES_SETTING); const RUNNING_TESTS_SETTING = new Setting('runningTests', ROOT_SETTING); const RESULTS_DISPLAY_SETTING = new Setting('resultsDisplay', ROOT_SETTING); +export const ADDITIONAL_TEST_ARGUMENTS_SETTING = new Setting('additionalTestArguments', RUNNING_TESTS_SETTING); export const NUMBER_OF_TEST_THREADS_SETTING = new Setting('numberOfThreads', RUNNING_TESTS_SETTING); export const MAX_QUERIES = new Setting('maxQueries', RUNNING_QUERIES_SETTING); export const AUTOSAVE_SETTING = new Setting('autoSave', RUNNING_QUERIES_SETTING); @@ -108,9 +109,10 @@ export interface QueryHistoryConfig { onDidChangeConfiguration: Event; } -const CLI_SETTINGS = [NUMBER_OF_TEST_THREADS_SETTING, NUMBER_OF_THREADS_SETTING]; +const CLI_SETTINGS = [ADDITIONAL_TEST_ARGUMENTS_SETTING, NUMBER_OF_TEST_THREADS_SETTING, NUMBER_OF_THREADS_SETTING]; export interface CliConfig { + additionalTestArguments: string[]; numberTestThreads: number; numberThreads: number; onDidChangeConfiguration?: Event; @@ -243,6 +245,9 @@ export class QueryHistoryConfigListener extends ConfigListener implements QueryH } export class CliConfigListener extends ConfigListener implements CliConfig { + public get additionalTestArguments(): string[] { + return ADDITIONAL_TEST_ARGUMENTS_SETTING.getValue(); + } public get numberTestThreads(): number { return NUMBER_OF_TEST_THREADS_SETTING.getValue();