From 9e58ef1c82cc02b9a183e589bbba60ecb255d5fb Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 1 Jun 2026 16:00:36 +0200 Subject: [PATCH] test(scripts): clean session log temp roots --- test/scripts/session-log-mentions.test.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/test/scripts/session-log-mentions.test.ts b/test/scripts/session-log-mentions.test.ts index db554367846..c6690ea04d1 100644 --- a/test/scripts/session-log-mentions.test.ts +++ b/test/scripts/session-log-mentions.test.ts @@ -1,17 +1,27 @@ +import { mkdtempSync, rmSync } from "node:fs"; import fs from "node:fs/promises"; -import path from "node:path"; import { tmpdir } from "node:os"; -import { mkdtempSync } from "node:fs"; -import { describe, expect, it } from "vitest"; +import path from "node:path"; +import { afterEach, describe, expect, it } from "vitest"; import { countSessionLogMentions, readSessionLogMentionLimits, } from "../../scripts/e2e/lib/session-log-mentions.ts"; +const tempRoots: string[] = []; + function makeTempRoot() { - return mkdtempSync(path.join(tmpdir(), "openclaw-session-log-mentions-")); + const root = mkdtempSync(path.join(tmpdir(), "openclaw-session-log-mentions-")); + tempRoots.push(root); + return root; } +afterEach(() => { + for (const root of tempRoots.splice(0)) { + rmSync(root, { force: true, recursive: true }); + } +}); + describe("session log mention scanner", () => { it("counts mentions across bounded session logs", async () => { const root = makeTempRoot();