Ensure --addtional-packs arg not used for empty workspace

This commit is contained in:
Andrew Eisenberg
2022-02-18 10:14:11 -08:00
parent eec72e0cbd
commit 251f354076
2 changed files with 20 additions and 12 deletions

View File

@@ -3,6 +3,7 @@
## [UNRELEASED] ## [UNRELEASED]
- Fix a bug where database upgrades could not be resolved if some of the target pack's dependencies are outside of the workspace. [#1138](https://github.com/github/vscode-codeql/pull/1138) - Fix a bug where database upgrades could not be resolved if some of the target pack's dependencies are outside of the workspace. [#1138](https://github.com/github/vscode-codeql/pull/1138)
- Fix a bug where queries took a long time to run if there are no folders in the workspace. [#1157](https://github.com/github/vscode-codeql/pull/1157)
## 1.5.11 - 10 February 2022 ## 1.5.11 - 10 February 2022

View File

@@ -514,8 +514,7 @@ export class CodeQLCliServer implements Disposable {
async resolveLibraryPath(workspaces: string[], queryPath: string): Promise<QuerySetup> { async resolveLibraryPath(workspaces: string[], queryPath: string): Promise<QuerySetup> {
const subcommandArgs = [ const subcommandArgs = [
'--query', queryPath, '--query', queryPath,
'--additional-packs', ...this.getAdditionalPacksArg(workspaces)
workspaces.join(path.delimiter)
]; ];
return await this.runJsonCodeQlCliCommand<QuerySetup>(['resolve', 'library-path'], subcommandArgs, 'Resolving library paths'); return await this.runJsonCodeQlCliCommand<QuerySetup>(['resolve', 'library-path'], subcommandArgs, 'Resolving library paths');
} }
@@ -528,8 +527,7 @@ export class CodeQLCliServer implements Disposable {
const subcommandArgs = [ const subcommandArgs = [
'--format', 'bylanguage', '--format', 'bylanguage',
queryUri.fsPath, queryUri.fsPath,
'--additional-packs', ...this.getAdditionalPacksArg(workspaces)
workspaces.join(path.delimiter)
]; ];
return JSON.parse(await this.runCodeQlCliCommand(['resolve', 'queries'], subcommandArgs, 'Resolving query by language')); return JSON.parse(await this.runCodeQlCliCommand(['resolve', 'queries'], subcommandArgs, 'Resolving query by language'));
} }
@@ -584,7 +582,7 @@ export class CodeQLCliServer implements Disposable {
): AsyncGenerator<TestCompleted, void, unknown> { ): AsyncGenerator<TestCompleted, void, unknown> {
const subcommandArgs = this.cliConfig.additionalTestArguments.concat([ const subcommandArgs = this.cliConfig.additionalTestArguments.concat([
'--additional-packs', workspaces.join(path.delimiter), ...this.getAdditionalPacksArg(workspaces),
'--threads', '--threads',
this.cliConfig.numberTestThreads.toString(), this.cliConfig.numberTestThreads.toString(),
...testPaths ...testPaths
@@ -606,8 +604,12 @@ export class CodeQLCliServer implements Disposable {
/** Resolves the ML models that should be available when evaluating a query. */ /** Resolves the ML models that should be available when evaluating a query. */
async resolveMlModels(additionalPacks: string[]): Promise<MlModelsInfo> { async resolveMlModels(additionalPacks: string[]): Promise<MlModelsInfo> {
return await this.runJsonCodeQlCliCommand<MlModelsInfo>(['resolve', 'ml-models'], ['--additional-packs', return await this.runJsonCodeQlCliCommand<MlModelsInfo>(
additionalPacks.join(path.delimiter)], 'Resolving ML models', false); ['resolve', 'ml-models'],
this.getAdditionalPacksArg(additionalPacks),
'Resolving ML models',
false
);
} }
/** /**
@@ -772,7 +774,7 @@ export class CodeQLCliServer implements Disposable {
* @returns A list of database upgrade script directories * @returns A list of database upgrade script directories
*/ */
async resolveUpgrades(dbScheme: string, searchPath: string[], allowDowngradesIfPossible: boolean, targetDbScheme?: string): Promise<UpgradesInfo> { async resolveUpgrades(dbScheme: string, searchPath: string[], allowDowngradesIfPossible: boolean, targetDbScheme?: string): Promise<UpgradesInfo> {
const args = ['--additional-packs', searchPath.join(path.delimiter), '--dbscheme', dbScheme]; const args = [...this.getAdditionalPacksArg(searchPath), '--dbscheme', dbScheme];
if (targetDbScheme) { if (targetDbScheme) {
args.push('--target-dbscheme', targetDbScheme); args.push('--target-dbscheme', targetDbScheme);
if (allowDowngradesIfPossible && await this.cliConstraints.supportsDowngrades()) { if (allowDowngradesIfPossible && await this.cliConstraints.supportsDowngrades()) {
@@ -794,7 +796,7 @@ export class CodeQLCliServer implements Disposable {
* @returns A dictionary mapping qlpack name to the directory it comes from * @returns A dictionary mapping qlpack name to the directory it comes from
*/ */
resolveQlpacks(additionalPacks: string[], searchPath?: string[]): Promise<QlpacksInfo> { resolveQlpacks(additionalPacks: string[], searchPath?: string[]): Promise<QlpacksInfo> {
const args = ['--additional-packs', additionalPacks.join(path.delimiter)]; const args = this.getAdditionalPacksArg(additionalPacks);
if (searchPath?.length) { if (searchPath?.length) {
args.push('--search-path', path.join(...searchPath)); args.push('--search-path', path.join(...searchPath));
} }
@@ -840,7 +842,7 @@ export class CodeQLCliServer implements Disposable {
* @returns A list of query files found. * @returns A list of query files found.
*/ */
async resolveQueriesInSuite(suite: string, additionalPacks: string[], searchPath?: string[]): Promise<string[]> { async resolveQueriesInSuite(suite: string, additionalPacks: string[], searchPath?: string[]): Promise<string[]> {
const args = ['--additional-packs', additionalPacks.join(path.delimiter)]; const args = this.getAdditionalPacksArg(additionalPacks);
if (searchPath !== undefined) { if (searchPath !== undefined) {
args.push('--search-path', path.join(...searchPath)); args.push('--search-path', path.join(...searchPath));
} }
@@ -873,8 +875,7 @@ export class CodeQLCliServer implements Disposable {
'-o', '-o',
outputPath, outputPath,
dir, dir,
'--additional-packs', ...this.getAdditionalPacksArg(workspaceFolders)
workspaceFolders.join(path.delimiter)
]; ];
if (!precompile && await this.cliConstraints.supportsNoPrecompile()) { if (!precompile && await this.cliConstraints.supportsNoPrecompile()) {
args.push('--no-precompile'); args.push('--no-precompile');
@@ -929,6 +930,12 @@ export class CodeQLCliServer implements Disposable {
throw new Error('No distribution found'); throw new Error('No distribution found');
} }
} }
private getAdditionalPacksArg(paths: string[]): string[] {
return paths.length
? ['--additional-packs', paths.join(path.delimiter)]
: [];
}
} }
/** /**