Skip to content

Commit b22c185

Browse files
committed
test(infra): clean exec approval temp roots
1 parent 07e3855 commit b22c185

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

‎src/infra/exec-approvals-test-helpers.ts‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,18 @@
22
import fs from "node:fs";
33
import os from "node:os";
44
import path from "node:path";
5+
import { afterEach } from "vitest";
56
import type { CommandResolution, ExecutableResolution } from "./exec-command-resolution.js";
67

8+
const tempDirs = new Set<string>();
9+
10+
afterEach(() => {
11+
for (const tempDir of tempDirs) {
12+
fs.rmSync(tempDir, { recursive: true, force: true });
13+
}
14+
tempDirs.clear();
15+
});
16+
717
// Shared exec-approval fixtures keep parser, allowlist, and wrapper tests on
818
// the same mock resolution shape.
919
export function makePathEnv(binDir: string): NodeJS.ProcessEnv {
@@ -15,7 +25,11 @@ export function makePathEnv(binDir: string): NodeJS.ProcessEnv {
1525

1626
/** Create a real temp directory for exec-approval tests that need filesystem paths. */
1727
export function makeTempDir(): string {
18-
return fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-exec-approvals-")));
28+
const tempDir = fs.realpathSync(
29+
fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-exec-approvals-")),
30+
);
31+
tempDirs.add(tempDir);
32+
return tempDir;
1933
}
2034

2135
/** Create an executable file in a test bin directory. */

0 commit comments

Comments
 (0)