Skip to content

Commit 0ed9242

Browse files
committed
Try waiting a few seconds before renaming
1 parent 3497219 commit 0ed9242

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

extensions/ql-vscode/test/vscode-tests/cli-integration/jest.setup.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { DB_URL, dbLoc, testprojLoc } from "../global.helper";
1111
import fetch from "node-fetch";
1212
import { renameSync } from "fs";
1313
import { unzipToDirectoryConcurrently } from "../../../src/common/unzip-concurrently";
14+
import { platform } from "os";
15+
import { wait } from "./utils";
1416

1517
beforeAll(async () => {
1618
// ensure the test database is downloaded
@@ -37,6 +39,11 @@ beforeAll(async () => {
3739
if (!existsSync(testprojLoc)) {
3840
console.log(`Unzipping test database to ${testprojLoc}`);
3941
await unzipToDirectoryConcurrently(dbLoc, dbParentDir);
42+
// On Windows, wait a few seconds to make sure all background processes
43+
// release their lock on the files before renaming the directory.
44+
if (platform() === "win32") {
45+
await wait(3000);
46+
}
4047
renameSync(join(dbParentDir, "db"), testprojLoc);
4148
console.log("Unzip completed.");
4249
}

extensions/ql-vscode/test/vscode-tests/cli-integration/utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ import { join } from "path";
77
export function getDataFolderFilePath(path: string): string {
88
return join(workspace.workspaceFolders![0].uri.fsPath, path);
99
}
10+
11+
export async function wait(ms = 1000) {
12+
return new Promise((resolve) => setTimeout(resolve, ms));
13+
}

extensions/ql-vscode/test/vscode-tests/minimal-workspace/local-queries/local-databases.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ describe("local databases", () => {
101101
onStart: () => {
102102
/**/
103103
},
104+
onQueryRunStarting: () => {
105+
/**/
106+
},
104107
}),
105108
mockedObject<CodeQLCliServer>({
106109
resolveDatabase: resolveDatabaseSpy,

0 commit comments

Comments
 (0)