Skip to content

Commit 43e4cdf

Browse files
committed
test(cli): use managed temp directory cleanup
Punchcard-Session: coral-workshop-workshop-3f
1 parent 51ecb41 commit 43e4cdf

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

‎src/cli/plugin-registry-loader.test.ts‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Plugin registry loader tests cover CLI plugin registry loading and cache reset behavior.
2-
import { mkdtemp, readFile, rm } from "node:fs/promises";
3-
import { tmpdir } from "node:os";
2+
import { readFile } from "node:fs/promises";
43
import { join } from "node:path";
54
import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
5+
import { useAutoCleanupTempDirTracker } from "../../test/helpers/temp-dir.js";
66
import { measureCliCommandStartup } from "./command-startup-timing.js";
77

88
const ensurePluginRegistryLoadedMock = vi.hoisted(() => vi.fn());
9-
const tempDirs: string[] = [];
9+
const tempDirs = useAutoCleanupTempDirTracker(afterEach);
1010

1111
vi.mock("./plugin-registry.js", () => ({
1212
ensurePluginRegistryLoaded: ensurePluginRegistryLoadedMock,
@@ -28,10 +28,9 @@ describe("plugin-registry-loader", () => {
2828
loggingState.forceConsoleToStderr = false;
2929
});
3030

31-
afterEach(async () => {
31+
afterEach(() => {
3232
loggingState.forceConsoleToStderr = originalForceStderr;
3333
vi.unstubAllEnvs();
34-
await Promise.all(tempDirs.splice(0).map((dir) => rm(dir, { recursive: true, force: true })));
3534
});
3635

3736
it("routes plugin load logs to stderr and restores state", async () => {
@@ -94,8 +93,7 @@ describe("plugin-registry-loader", () => {
9493
});
9594

9695
it("attributes module import separately from runtime loading", async () => {
97-
const dir = await mkdtemp(join(tmpdir(), "openclaw-plugin-registry-startup-"));
98-
tempDirs.push(dir);
96+
const dir = tempDirs.make("openclaw-plugin-registry-startup-");
9997
const timelinePath = join(dir, "timeline.jsonl");
10098
vi.stubEnv("OPENCLAW_DIAGNOSTICS", "timeline");
10199
vi.stubEnv("OPENCLAW_DIAGNOSTICS_TIMELINE_PATH", timelinePath);

0 commit comments

Comments
 (0)