mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-14 02:31:24 +00:00
test(plugins): reuse tracked temp helpers in fixture tests
This commit is contained in:
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user