Set `unsafeCleanup` for all test tmp directories

We want to remove the tmp directories after tests, even if they are not
empty.
This commit is contained in:
Koen Vlaswinkel 2023-12-14 15:08:40 +01:00
Родитель 889055ee19
Коммит d63b756520
11 изменённых файлов: 36 добавлений и 15 удалений

Просмотреть файл

@ -9,7 +9,9 @@ import {
describe("isLikelyDatabaseRoot", () => {
let dir: tmp.DirResult;
beforeEach(() => {
dir = tmp.dirSync();
dir = tmp.dirSync({
unsafeCleanup: true,
});
});
afterEach(() => {
@ -54,7 +56,9 @@ describe("isLikelyDatabaseRoot", () => {
describe("isLikelyDbLanguageFolder", () => {
let dir: tmp.DirResult;
beforeEach(() => {
dir = tmp.dirSync();
dir = tmp.dirSync({
unsafeCleanup: true,
});
});
afterEach(() => {

Просмотреть файл

@ -10,7 +10,9 @@ describe("getInitialQueryContents", () => {
let language: QueryLanguage;
beforeEach(() => {
dir = tmp.dirSync();
dir = tmp.dirSync({
unsafeCleanup: true,
});
language = QueryLanguage.Cpp;
const contents = dump({

Просмотреть файл

@ -61,6 +61,7 @@ describe("modeled-method-fs", () => {
process.platform === "win32"
? join(homedir(), "AppData", "Local", "Temp")
: undefined,
unsafeCleanup: true,
});
tmpDir = t.name;
tmpDirRemoveCallback = t.removeCallback;

Просмотреть файл

@ -19,7 +19,9 @@ let removeStorage: tmp.DirResult["removeCallback"] | undefined;
export async function beforeAllAction() {
// Create the temp directory to be used as extension local storage.
const dir = tmp.dirSync();
const dir = tmp.dirSync({
unsafeCleanup: true,
});
let storagePath = realpathSync(dir.name);
if (storagePath.substring(0, 2).match(/[A-Z]:/)) {
storagePath =

Просмотреть файл

@ -83,7 +83,9 @@ describe("FilePathDiscovery", () => {
let discovery: TestFilePathDiscovery;
beforeEach(() => {
const t = tmp.dirSync();
const t = tmp.dirSync({
unsafeCleanup: true,
});
tmpDir = normalizePath(t.name);
tmpDirRemoveCallback = t.removeCallback;

Просмотреть файл

@ -52,7 +52,9 @@ describe("local databases", () => {
let extensionContextStoragePath: string;
beforeEach(() => {
dir = tmp.dirSync();
dir = tmp.dirSync({
unsafeCleanup: true,
});
updateSpy = jest.fn(() => Promise.resolve(undefined));
registerSpy = jest.fn(() => Promise.resolve(undefined));

Просмотреть файл

@ -25,7 +25,9 @@ describe("QlPackGenerator", () => {
let dir: tmp.DirResult;
beforeEach(async () => {
dir = tmp.dirSync();
dir = tmp.dirSync({
unsafeCleanup: true,
});
language = "ruby";
packFolderPath = Uri.file(

Просмотреть файл

@ -31,7 +31,9 @@ describe("Query pack discovery", () => {
let discovery: QueryDiscovery;
beforeEach(() => {
const t = tmp.dirSync();
const t = tmp.dirSync({
unsafeCleanup: true,
});
tmpDir = t.name;
tmpDirRemoveCallback = t.removeCallback;

Просмотреть файл

@ -18,7 +18,9 @@ describe("Query pack discovery", () => {
let discovery: QueryPackDiscovery;
beforeEach(() => {
const t = tmp.dirSync();
const t = tmp.dirSync({
unsafeCleanup: true,
});
tmpDir = t.name;
tmpDirRemoveCallback = t.removeCallback;

Просмотреть файл

@ -14,7 +14,9 @@ describe("prepareCodeTour", () => {
>;
beforeEach(() => {
dir = tmp.dirSync();
dir = tmp.dirSync({
unsafeCleanup: true,
});
const mockWorkspaceFolders = [
{

Просмотреть файл

@ -18,7 +18,7 @@ describe("local-databases-ui", () => {
describe("fixDbUri", () => {
const fixDbUri = (DatabaseUI.prototype as any).fixDbUri;
it("should choose current directory normally", async () => {
const dir = dirSync().name;
const dir = dirSync({ unsafeCleanup: true }).name;
const uri = await fixDbUri(Uri.file(dir));
expect(uri.toString()).toBe(Uri.file(dir).toString());
});
@ -30,7 +30,7 @@ describe("local-databases-ui", () => {
});
it("should choose parent directory when db-* is selected", async () => {
const dir = dirSync().name;
const dir = dirSync({ unsafeCleanup: true }).name;
const dbDir = join(dir, "db-javascript");
await mkdirs(dbDir);
@ -39,7 +39,7 @@ describe("local-databases-ui", () => {
});
it("should choose parent's parent directory when file selected is in db-*", async () => {
const dir = dirSync().name;
const dir = dirSync({ unsafeCleanup: true }).name;
const dbDir = join(dir, "db-javascript");
const file = join(dbDir, "nested");
await mkdirs(dbDir);
@ -51,7 +51,7 @@ describe("local-databases-ui", () => {
it("should handle a parent whose name is db-*", async () => {
// fixes https://github.com/github/vscode-codeql/issues/482
const dir = dirSync().name;
const dir = dirSync({ unsafeCleanup: true }).name;
const parentDir = join(dir, "db-hucairz");
const dbDir = join(parentDir, "db-javascript");
const file = join(dbDir, "nested");
@ -64,7 +64,7 @@ describe("local-databases-ui", () => {
});
it("should delete orphaned databases", async () => {
const storageDir = dirSync().name;
const storageDir = dirSync({ unsafeCleanup: true }).name;
const db1 = createDatabase(storageDir, "db1-imported", QueryLanguage.Cpp);
const db2 = createDatabase(
storageDir,