Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tests with workspaceContains:.git activation event #3086

Merged
merged 3 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 2 additions & 1 deletion extensions/ql-vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"onWebviewPanel:resultsView",
"onWebviewPanel:codeQL.variantAnalysis",
"onWebviewPanel:codeQL.dataFlowPaths",
"onFileSystem:codeql-zip-archive"
"onFileSystem:codeql-zip-archive",
"workspaceContains:.git"
],
"main": "./out/extension",
"files": [
Expand Down
6 changes: 2 additions & 4 deletions extensions/ql-vscode/src/codeql-cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,11 @@ export class CodeQLCliServer implements Disposable {
if (this.distributionProvider.onDidChangeDistribution) {
this.distributionProvider.onDidChangeDistribution(() => {
this.restartCliServer();
this._version = undefined;
this._supportedLanguages = undefined;
});
}
if (this.cliConfig.onDidChangeConfiguration) {
this.cliConfig.onDidChangeConfiguration(() => {
this.restartCliServer();
this._version = undefined;
this._supportedLanguages = undefined;
});
}
}
Expand Down Expand Up @@ -290,6 +286,8 @@ export class CodeQLCliServer implements Disposable {
const callback = (): void => {
try {
this.killProcessIfRunning();
this._version = undefined;
this._supportedLanguages = undefined;
} finally {
this.runNext();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
storagePath,
} from "../../global.helper";
import { createMockCommandManager } from "../../../__mocks__/commandsMock";
import { ensureDir, remove } from "fs-extra";

/**
* Run various integration tests for databases
Expand All @@ -41,6 +42,8 @@ describe("database-fetcher", () => {

afterEach(async () => {
await cleanDatabases(databaseManager);
await remove(storagePath);
await ensureDir(storagePath);
charisk marked this conversation as resolved.
Show resolved Hide resolved
});

describe("importArchiveDatabase", () => {
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 } from "../global.helper";
import { DB_URL, dbLoc, getActivatedExtension } from "../global.helper";
import fetch from "node-fetch";

beforeAll(async () => {
Expand All @@ -31,6 +31,25 @@ 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) {
// This calls the private `updateConfiguration` method in the `ConfigListener`
// It seems like the CUSTOM_CODEQL_PATH_SETTING.updateValue() call in
charisk marked this conversation as resolved.
Show resolved Hide resolved
// `beforeAllAction` doesn't fire the event that the config has changed.
// This is a hacky workaround.
(
extension.distributionManager.config as unknown as {
updateConfiguration: () => void;
}
).updateConfiguration();
}
}
});

beforeEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,20 +53,6 @@ describe("modeled-method-fs", () => {
let workspacePath: string;
let cli: CodeQLCliServer;

beforeAll(async () => {
const extension = await getActivatedExtension();
cli = extension.cliServer;

// All transitive dependencies must be available for resolve extensions to succeed.
const packUsingExtensionsPath = join(
__dirname,
"../../..",
"data-extensions",
"pack-using-extensions",
);
await cli.packInstall(packUsingExtensionsPath);
});

beforeEach(async () => {
// On windows, make sure to use a temp directory that isn't an alias and therefore won't be canonicalised by CodeQL.
// See https://github.com/github/vscode-codeql/pull/2605 for more context.
Expand All @@ -92,6 +78,15 @@ describe("modeled-method-fs", () => {

const extension = await getActivatedExtension();
cli = extension.cliServer;

// All transitive dependencies must be available for resolve extensions to succeed.
const packUsingExtensionsPath = join(
__dirname,
"../../..",
"data-extensions",
"pack-using-extensions",
);
await cli.packInstall(packUsingExtensionsPath);
});

afterEach(() => {
Expand Down
Loading