Allow the CodeQL CLI path to be set from an environment variable (#3118)
This commit is contained in:
@@ -119,14 +119,6 @@ export interface DistributionConfig {
|
||||
ownerName?: string;
|
||||
repositoryName?: string;
|
||||
onDidChangeConfiguration?: Event<void>;
|
||||
|
||||
/**
|
||||
* This forces an update of the distribution, even if the settings haven't changed.
|
||||
*
|
||||
* This should only be used when the distribution has been updated outside of the extension
|
||||
* and only in tests. It should not be called in production code.
|
||||
*/
|
||||
forceUpdateConfiguration(): void;
|
||||
}
|
||||
|
||||
// Query server configuration
|
||||
@@ -265,7 +257,10 @@ export class DistributionConfigListener
|
||||
implements DistributionConfig
|
||||
{
|
||||
public get customCodeQlPath(): string | undefined {
|
||||
return CUSTOM_CODEQL_PATH_SETTING.getValue() || undefined;
|
||||
const testCliPath =
|
||||
isIntegrationTestMode() &&
|
||||
process.env.VSCODE_CODEQL_TESTING_CODEQL_CLI_TEST_PATH;
|
||||
return CUSTOM_CODEQL_PATH_SETTING.getValue() || testCliPath || undefined;
|
||||
}
|
||||
|
||||
public get includePrerelease(): boolean {
|
||||
@@ -283,10 +278,6 @@ export class DistributionConfigListener
|
||||
);
|
||||
}
|
||||
|
||||
public forceUpdateConfiguration() {
|
||||
this._onDidChangeConfiguration.fire(undefined);
|
||||
}
|
||||
|
||||
protected handleDidChangeConfiguration(e: ConfigurationChangeEvent): void {
|
||||
this.handleDidChangeConfigurationForRelevantSettings(
|
||||
DISTRIBUTION_CHANGE_SETTINGS,
|
||||
|
||||
@@ -22,6 +22,7 @@ const config = {
|
||||
extensionTestsEnv: {
|
||||
...baseConfig.extensionTestsEnv,
|
||||
INTEGRATION_TEST_MODE: "true",
|
||||
VSCODE_CODEQL_TESTING_CODEQL_CLI_TEST_PATH: process.env.CLI_PATH,
|
||||
},
|
||||
retries: 3,
|
||||
};
|
||||
|
||||
@@ -35,6 +35,7 @@ const config = {
|
||||
extensionTestsEnv: {
|
||||
...baseConfig.extensionTestsEnv,
|
||||
INTEGRATION_TEST_MODE: "true",
|
||||
VSCODE_CODEQL_TESTING_CODEQL_CLI_TEST_PATH: process.env.CLI_PATH,
|
||||
},
|
||||
retries: 3,
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from "../jest.activated-extension.setup";
|
||||
import { createWriteStream, existsSync, mkdirpSync } from "fs-extra";
|
||||
import { dirname } from "path";
|
||||
import { DB_URL, dbLoc, getActivatedExtension } from "../global.helper";
|
||||
import { DB_URL, dbLoc } from "../global.helper";
|
||||
import fetch from "node-fetch";
|
||||
|
||||
beforeAll(async () => {
|
||||
@@ -31,21 +31,6 @@ beforeAll(async () => {
|
||||
}
|
||||
|
||||
await beforeAllAction();
|
||||
|
||||
// Activate the extension
|
||||
const extension = await getActivatedExtension();
|
||||
|
||||
if (process.env.CLI_VERSION && process.env.CLI_VERSION !== "nightly") {
|
||||
const cliVersion = await extension.cliServer.getVersion();
|
||||
|
||||
if (cliVersion.compare(process.env.CLI_VERSION) !== 0) {
|
||||
// It seems like the CUSTOM_CODEQL_PATH_SETTING.updateValue() call in
|
||||
// `beforeAllAction` doesn't fire the event that the config has changed.
|
||||
// `forceUpdateConfiguration` will fire the event manually.
|
||||
// This is a hacky workaround.
|
||||
extension.distributionManager.config.forceUpdateConfiguration();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { CUSTOM_CODEQL_PATH_SETTING } from "../../src/config";
|
||||
import { ConfigurationTarget, env } from "vscode";
|
||||
import { env } from "vscode";
|
||||
import { beforeEachAction as testConfigBeforeEachAction } from "./test-config";
|
||||
import * as tmp from "tmp";
|
||||
import { realpathSync } from "fs-extra";
|
||||
@@ -19,13 +18,6 @@ if (process.env.CI) {
|
||||
let removeStorage: tmp.DirResult["removeCallback"] | undefined;
|
||||
|
||||
export async function beforeAllAction() {
|
||||
// Set the CLI version here before activation to ensure we don't accidentally try to download a cli
|
||||
await testConfigBeforeEachAction();
|
||||
await CUSTOM_CODEQL_PATH_SETTING.updateValue(
|
||||
process.env.CLI_PATH,
|
||||
ConfigurationTarget.Workspace,
|
||||
);
|
||||
|
||||
// Create the temp directory to be used as extension local storage.
|
||||
const dir = tmp.dirSync();
|
||||
let storagePath = realpathSync(dir.name);
|
||||
@@ -46,11 +38,6 @@ export async function beforeEachAction() {
|
||||
jest.spyOn(env, "openExternal").mockResolvedValue(false);
|
||||
|
||||
await testConfigBeforeEachAction();
|
||||
|
||||
await CUSTOM_CODEQL_PATH_SETTING.updateValue(
|
||||
process.env.CLI_PATH,
|
||||
ConfigurationTarget.Workspace,
|
||||
);
|
||||
}
|
||||
|
||||
export async function afterAllAction() {
|
||||
|
||||
Reference in New Issue
Block a user