diff --git a/packages/eve/src/internal/testing/use-temporary-app-roots.ts b/packages/eve/src/internal/testing/use-temporary-app-roots.ts index c52f9b1cb..46e8b3e74 100644 --- a/packages/eve/src/internal/testing/use-temporary-app-roots.ts +++ b/packages/eve/src/internal/testing/use-temporary-app-roots.ts @@ -41,28 +41,12 @@ export function useTemporaryAppRoots(): ( prefix: string, options?: CreateTemporaryAppRootOptions, ) => Promise { - const temporaryRoots: string[] = []; - - afterEach(async () => { - await Promise.all( - temporaryRoots.splice(0).map(async (directoryPath) => { - try { - await rm(directoryPath, { - force: true, - recursive: true, - }); - } catch { - // Best-effort cleanup; a leaked tmpdir must not fail the run. - } - }), - ); - }); + const createTemporaryDirectory = useTemporaryDirectories(); return async (prefix, options = {}) => { - const appRoot = await mkdtemp(join(tmpdir(), prefix)); + const appRoot = await createTemporaryDirectory(prefix); const agentRoot = join(appRoot, "agent"); - temporaryRoots.push(appRoot); await mkdir(agentRoot, { recursive: true, }); @@ -110,7 +94,7 @@ export function useTemporaryDirectories(): (prefix: string) => Promise { recursive: true, }); } catch { - // Best-effort cleanup. + // A leaked temporary directory must not fail the test. } }), );