mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 13:44:32 +00:00
perf(test): speed up archive suite
This commit is contained in:
@@ -3,25 +3,24 @@ import fs from "node:fs/promises";
|
|||||||
import os from "node:os";
|
import os from "node:os";
|
||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import * as tar from "tar";
|
import * as tar from "tar";
|
||||||
import { afterEach, describe, expect, it } from "vitest";
|
import { afterAll, beforeAll, describe, expect, it } from "vitest";
|
||||||
import { extractArchive, resolveArchiveKind, resolvePackedRootDir } from "./archive.js";
|
import { extractArchive, resolveArchiveKind, resolvePackedRootDir } from "./archive.js";
|
||||||
|
|
||||||
const tempDirs: string[] = [];
|
let fixtureRoot = "";
|
||||||
|
let fixtureCount = 0;
|
||||||
|
|
||||||
async function makeTempDir() {
|
async function makeTempDir(prefix = "case") {
|
||||||
const dir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-archive-"));
|
const dir = path.join(fixtureRoot, `${prefix}-${fixtureCount++}`);
|
||||||
tempDirs.push(dir);
|
await fs.mkdir(dir, { recursive: true });
|
||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
afterEach(async () => {
|
beforeAll(async () => {
|
||||||
for (const dir of tempDirs.splice(0)) {
|
fixtureRoot = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-archive-"));
|
||||||
try {
|
});
|
||||||
await fs.rm(dir, { recursive: true, force: true });
|
|
||||||
} catch {
|
afterAll(async () => {
|
||||||
// ignore cleanup failures
|
await fs.rm(fixtureRoot, { recursive: true, force: true });
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("archive utils", () => {
|
describe("archive utils", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user