From 221fe499dbe327ad10d6595e0d04fa33ada0eac7 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 14 Feb 2026 22:01:17 +0000 Subject: [PATCH] perf(test): speed up archive suite --- src/infra/archive.test.ts | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/infra/archive.test.ts b/src/infra/archive.test.ts index b853afc6a40..825f215db1b 100644 --- a/src/infra/archive.test.ts +++ b/src/infra/archive.test.ts @@ -3,25 +3,24 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; 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"; -const tempDirs: string[] = []; +let fixtureRoot = ""; +let fixtureCount = 0; -async function makeTempDir() { - const dir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-archive-")); - tempDirs.push(dir); +async function makeTempDir(prefix = "case") { + const dir = path.join(fixtureRoot, `${prefix}-${fixtureCount++}`); + await fs.mkdir(dir, { recursive: true }); return dir; } -afterEach(async () => { - for (const dir of tempDirs.splice(0)) { - try { - await fs.rm(dir, { recursive: true, force: true }); - } catch { - // ignore cleanup failures - } - } +beforeAll(async () => { + fixtureRoot = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-archive-")); +}); + +afterAll(async () => { + await fs.rm(fixtureRoot, { recursive: true, force: true }); }); describe("archive utils", () => {