test(plugins): reuse tracked temp helpers in fixture tests

This commit is contained in:
Vincent Koc
2026-04-06 05:50:11 +01:00
parent 26c34f816d
commit f3f42e6bbf
4 changed files with 19 additions and 21 deletions

View File

@@ -1,16 +1,14 @@
import fs from "node:fs";
import os from "node:os";
import path from "node:path";
import { pathToFileURL } from "node:url";
import { afterEach, describe, expect, it } from "vitest";
import { cleanupTrackedTempDirs, makeTrackedTempDir } from "../test-helpers/fs-fixtures.js";
import { loadSiblingRuntimeModuleSync } from "./local-runtime-module.js";
const tempDirs = new Set<string>();
const tempDirs: string[] = [];
function createTempDir(): string {
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-local-runtime-module-"));
tempDirs.add(dir);
return dir;
return makeTrackedTempDir("openclaw-local-runtime-module", tempDirs);
}
function writeFile(filePath: string, content: string): void {
@@ -19,10 +17,7 @@ function writeFile(filePath: string, content: string): void {
}
afterEach(() => {
for (const dir of tempDirs) {
fs.rmSync(dir, { recursive: true, force: true });
}
tempDirs.clear();
cleanupTrackedTempDirs(tempDirs);
});
describe("loadSiblingRuntimeModuleSync", () => {