mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-17 20:21:13 +00:00
test(plugins): reuse tracked temp helpers in loader fixture tests
This commit is contained in:
@@ -1,27 +1,14 @@
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterAll, describe, expect, it } from "vitest";
|
||||
import { cleanupTrackedTempDirs, makeTrackedTempDir } from "./test-helpers/fs-fixtures.js";
|
||||
|
||||
function mkdtempSafe(prefix: string) {
|
||||
const dir = fs.mkdtempSync(prefix);
|
||||
try {
|
||||
fs.chmodSync(dir, 0o755);
|
||||
} catch {
|
||||
// Best-effort
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
const fixtureRoot = mkdtempSafe(path.join(os.tmpdir(), "openclaw-plugin-graceful-"));
|
||||
const fixtureTempDirs: string[] = [];
|
||||
const fixtureRoot = makeTrackedTempDir("openclaw-plugin-graceful", fixtureTempDirs);
|
||||
let tempDirIndex = 0;
|
||||
|
||||
afterAll(() => {
|
||||
try {
|
||||
fs.rmSync(fixtureRoot, { recursive: true, force: true });
|
||||
} catch {
|
||||
// Ignore cleanup errors
|
||||
}
|
||||
cleanupTrackedTempDirs(fixtureTempDirs);
|
||||
});
|
||||
|
||||
function makeTempDir() {
|
||||
|
||||
@@ -19,7 +19,11 @@ import {
|
||||
resolvePluginSdkAliasFile,
|
||||
shouldPreferNativeJiti,
|
||||
} from "./sdk-alias.js";
|
||||
import { makeTrackedTempDir, mkdirSafeDir } from "./test-helpers/fs-fixtures.js";
|
||||
import {
|
||||
cleanupTrackedTempDirs,
|
||||
makeTrackedTempDir,
|
||||
mkdirSafeDir,
|
||||
} from "./test-helpers/fs-fixtures.js";
|
||||
|
||||
type CreateJiti = typeof import("jiti").createJiti;
|
||||
|
||||
@@ -305,7 +309,7 @@ function expectCwdFallbackPluginSdkAliasResolution(params: {
|
||||
}
|
||||
|
||||
afterAll(() => {
|
||||
fs.rmSync(fixtureRoot, { recursive: true, force: true });
|
||||
cleanupTrackedTempDirs(fixtureTempDirs);
|
||||
});
|
||||
|
||||
describe("plugin sdk alias helpers", () => {
|
||||
|
||||
Reference in New Issue
Block a user