Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 4 additions & 13 deletions extensions/ql-vscode/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -283,10 +278,6 @@ export class DistributionConfigListener
);
}

public forceUpdateConfiguration() {
this._onDidChangeConfiguration.fire(undefined);
}

protected handleDidChangeConfiguration(e: ConfigurationChangeEvent): void {
this.handleDidChangeConfigurationForRelevantSettings(
DISTRIBUTION_CHANGE_SETTINGS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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();
Comment thread
charisk marked this conversation as resolved.
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);
Expand All @@ -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() {
Expand Down