mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-03 06:50:22 +00:00
test(plugins): reuse tracked temp helpers in path resolution tests
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { resolveBundledPluginsDir } from "./bundled-dir.js";
|
||||
import { cleanupTrackedTempDirs, makeTrackedTempDir } from "./test-helpers/fs-fixtures.js";
|
||||
|
||||
const tempDirs: string[] = [];
|
||||
const originalBundledDir = process.env.OPENCLAW_BUNDLED_PLUGINS_DIR;
|
||||
@@ -11,9 +11,7 @@ const originalVitest = process.env.VITEST;
|
||||
const originalArgv1 = process.argv[1];
|
||||
|
||||
function makeRepoRoot(prefix: string): string {
|
||||
const repoRoot = fs.mkdtempSync(path.join(os.tmpdir(), prefix));
|
||||
tempDirs.push(repoRoot);
|
||||
return repoRoot;
|
||||
return makeTrackedTempDir(prefix, tempDirs);
|
||||
}
|
||||
|
||||
function createOpenClawRoot(params: {
|
||||
@@ -140,9 +138,7 @@ afterEach(() => {
|
||||
process.env.VITEST = originalVitest;
|
||||
}
|
||||
process.argv[1] = originalArgv1;
|
||||
for (const dir of tempDirs.splice(0, tempDirs.length)) {
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
cleanupTrackedTempDirs(tempDirs);
|
||||
});
|
||||
|
||||
describe("resolveBundledPluginsDir", () => {
|
||||
|
||||
@@ -1,25 +1,23 @@
|
||||
import { execFileSync } from "node:child_process";
|
||||
import fs from "node:fs";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import {
|
||||
cleanupTrackedTempDirs,
|
||||
makeTrackedTempDir,
|
||||
mkdirSafeDir,
|
||||
} from "./test-helpers/fs-fixtures.js";
|
||||
|
||||
const tempRoots: string[] = [];
|
||||
|
||||
function makeTempDir() {
|
||||
const dir = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-plugin-loader-"));
|
||||
tempRoots.push(dir);
|
||||
return dir;
|
||||
return makeTrackedTempDir("openclaw-plugin-loader", tempRoots);
|
||||
}
|
||||
|
||||
function mkdirSafe(dir: string) {
|
||||
fs.mkdirSync(dir, { recursive: true });
|
||||
}
|
||||
const mkdirSafe = mkdirSafeDir;
|
||||
|
||||
afterEach(() => {
|
||||
for (const dir of tempRoots.splice(0)) {
|
||||
fs.rmSync(dir, { recursive: true, force: true });
|
||||
}
|
||||
cleanupTrackedTempDirs(tempRoots);
|
||||
});
|
||||
|
||||
describe("plugin loader git path regression", () => {
|
||||
|
||||
Reference in New Issue
Block a user