Skip to content

OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security

test: make temporary directory cleanup idempotent (#7)

mldangelo-oai36102d4e42a7
diff --git a/sdk/typescript/tests-ts/config.test.ts b/sdk/typescript/tests-ts/config.test.ts
index 416040310..7a16e9c54 100644
--- a/sdk/typescript/tests-ts/config.test.ts
+++ b/sdk/typescript/tests-ts/config.test.ts
@@ -25,7 +25,9 @@ const temporaryDirectories: string[] = [];
afterEach(async () => {
await Promise.all(
- temporaryDirectories.splice(0).map((path) => rm(path, { recursive: true })),
+ temporaryDirectories
+ .splice(0)
+ .map((path) => rm(path, { recursive: true, force: true })),
);
});
diff --git a/sdk/typescript/tests-ts/contract.test.ts b/sdk/typescript/tests-ts/contract.test.ts
index 6c6de60ba..5b0913050 100644
--- a/sdk/typescript/tests-ts/contract.test.ts
+++ b/sdk/typescript/tests-ts/contract.test.ts
@@ -22,7 +22,9 @@ const temporaryDirectories: string[] = [];
afterEach(async () => {
await Promise.all(
- temporaryDirectories.splice(0).map((path) => rm(path, { recursive: true })),
+ temporaryDirectories
+ .splice(0)
+ .map((path) => rm(path, { recursive: true, force: true })),
);
});
diff --git a/sdk/typescript/tests-ts/runtime.test.ts b/sdk/typescript/tests-ts/runtime.test.ts
index da2cf6bc7..6da0317f4 100644
--- a/sdk/typescript/tests-ts/runtime.test.ts
+++ b/sdk/typescript/tests-ts/runtime.test.ts
@@ -44,7 +44,9 @@ const testPosix = process.platform === "win32" ? test.skip : test;
afterEach(async () => {
await Promise.all(
- temporaryDirectories.splice(0).map((path) => rm(path, { recursive: true })),
+ temporaryDirectories
+ .splice(0)
+ .map((path) => rm(path, { recursive: true, force: true })),
);
});
diff --git a/sdk/typescript/tests-ts/targets.test.ts b/sdk/typescript/tests-ts/targets.test.ts
index d674f1926..43f3c3dfb 100644
--- a/sdk/typescript/tests-ts/targets.test.ts
+++ b/sdk/typescript/tests-ts/targets.test.ts
@@ -25,7 +25,9 @@ const temporaryDirectories: string[] = [];
afterEach(async () => {
await Promise.all(
- temporaryDirectories.splice(0).map((path) => rm(path, { recursive: true })),
+ temporaryDirectories
+ .splice(0)
+ .map((path) => rm(path, { recursive: true, force: true })),
);
});
@@ -48,6 +50,11 @@ function git(repo: string, ...args: string[]): string {
}
describe("scan target normalization", () => {
+ test("tolerates a temporary repository removed before cleanup", async () => {
+ const repo = await repository();
+ await rm(join(repo, ".."), { recursive: true });
+ });
+
test("normalizes repository and path targets", async () => {
const repo = await repository();
expect(await normalizeTarget(repo, "repository")).toEqual({