@@ -6,7 +6,7 @@ import fs from "node:fs/promises";
66import os from "node:os" ;
77import path from "node:path" ;
88import { promisify } from "node:util" ;
9- import { afterAll , afterEach , beforeAll , beforeEach , expect , test , vi } from "vitest" ;
9+ import { afterEach , beforeEach , expect , test , vi } from "vitest" ;
1010import { useAutoCleanupTempDirTracker } from "../../test/helpers/temp-dir.js" ;
1111import { getContextWindowCaches } from "../agents/context-cache.js" ;
1212import {
@@ -163,13 +163,14 @@ vi.mock("./session-transcript-readers.js", async (importOriginal) => {
163163 return { ...actual , readSessionMessageCountAsync : sessionTranscriptReaderMocks . readCount } ;
164164} ) ;
165165
166+ let gitWorkspaceTemplate : string ;
166167const { createSessionStoreDir, createSelectedGlobalSessionStore, openClient } =
167- setupGatewaySessionsTestHarness ( ) ;
168+ setupGatewaySessionsTestHarness ( async ( makeTempDir ) => {
169+ gitWorkspaceTemplate = await createGitWorkspace ( makeTempDir ( "openclaw-session-git-template-" ) ) ;
170+ } ) ;
168171const execFileAsync = promisify ( execFile ) ;
169172const tempDirs = useAutoCleanupTempDirTracker ( afterEach ) ;
170173const directoryLinkType = process . platform === "win32" ? "junction" : "dir" ;
171- let gitWorkspaceTemplateRoot : string ;
172- let gitWorkspaceTemplate : string ;
173174
174175async function waitForCreatedSessionRun (
175176 context : { chatAbortControllers : Map < string , ChatAbortControllerEntry > } ,
@@ -195,17 +196,6 @@ async function waitForCreatedSessionRun(
195196 return removed ;
196197}
197198
198- beforeAll ( async ( ) => {
199- gitWorkspaceTemplateRoot = await fs . realpath (
200- await fs . mkdtemp ( path . join ( await fs . realpath ( os . tmpdir ( ) ) , "openclaw-session-git-template-" ) ) ,
201- ) ;
202- gitWorkspaceTemplate = await createGitWorkspace ( gitWorkspaceTemplateRoot ) ;
203- } ) ;
204-
205- afterAll ( async ( ) => {
206- await fs . rm ( gitWorkspaceTemplateRoot , { recursive : true , force : true } ) ;
207- } ) ;
208-
209199// Read the real implementations back here rather than capturing them inside the
210200// mock factories: Vitest runs a factory on first import of the mocked module, and
211201// this project is `isolate: false`, so on a warm module graph a factory can still
0 commit comments