From 696a358215563029a52385ede84407e6cea15d4e Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 14 Feb 2026 21:10:13 +0000 Subject: [PATCH] perf(test): speed up update-runner suite --- src/infra/update-runner.test.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/infra/update-runner.test.ts b/src/infra/update-runner.test.ts index f4ac1d70115..c56a9d78eb8 100644 --- a/src/infra/update-runner.test.ts +++ b/src/infra/update-runner.test.ts @@ -1,7 +1,7 @@ import fs from "node:fs/promises"; import os from "node:os"; import path from "node:path"; -import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; +import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; import { pathExists } from "../utils.js"; import { runGatewayUpdate } from "./update-runner.js"; @@ -23,15 +23,28 @@ function createRunner(responses: Record) { } describe("runGatewayUpdate", () => { + let fixtureRoot = ""; + let caseId = 0; let tempDir: string; + beforeAll(async () => { + fixtureRoot = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-update-")); + }); + + afterAll(async () => { + if (fixtureRoot) { + await fs.rm(fixtureRoot, { recursive: true, force: true }); + } + }); + beforeEach(async () => { - tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-update-")); + tempDir = path.join(fixtureRoot, `case-${caseId++}`); + await fs.mkdir(tempDir, { recursive: true }); await fs.writeFile(path.join(tempDir, "openclaw.mjs"), "export {};\n", "utf-8"); }); afterEach(async () => { - await fs.rm(tempDir, { recursive: true, force: true }); + // Shared fixtureRoot cleaned up in afterAll. }); it("skips git update when worktree is dirty", async () => {