11import fs from "node:fs/promises" ;
2- import os from "node:os" ;
32import path from "node:path" ;
43import { afterEach , beforeEach , describe , expect , it , vi } from "vitest" ;
4+ import { useAutoCleanupTempDirTracker } from "../../test/helpers/temp-dir.js" ;
55import type { PermissionCheck } from "./audit-fs.js" ;
66import { validateInstallPolicyStatic } from "./install-policy.js" ;
77
@@ -17,7 +17,7 @@ vi.mock("./audit-fs.js", async (importOriginal) => {
1717 } ;
1818} ) ;
1919
20- const tempDirs : string [ ] = [ ] ;
20+ const tempDirs = useAutoCleanupTempDirTracker ( afterEach ) ;
2121
2222function permissions ( source : PermissionCheck [ "source" ] ) : PermissionCheck {
2323 return {
@@ -39,19 +39,17 @@ beforeEach(() => {
3939 auditMocks . inspectPathPermissions . mockResolvedValue ( permissions ( "windows-acl" ) ) ;
4040} ) ;
4141
42- afterEach ( async ( ) => {
42+ afterEach ( ( ) => {
4343 vi . restoreAllMocks ( ) ;
4444 auditMocks . inspectPathPermissions . mockReset ( ) ;
45- await Promise . all ( tempDirs . splice ( 0 ) . map ( ( dir ) => fs . rm ( dir , { recursive : true , force : true } ) ) ) ;
4645} ) ;
4746
4847describe ( "install policy Windows ACL diagnostics" , ( ) => {
4948 it . each ( [
5049 { kind : "file" , unavailablePath : ( scriptPath : string ) => scriptPath } ,
5150 { kind : "parent directory" , unavailablePath : ( scriptPath : string ) => path . dirname ( scriptPath ) } ,
5251 ] ) ( "identifies the interpreter script when its $kind ACL is unavailable" , async ( fixture ) => {
53- const dir = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , "openclaw-install-policy-windows-" ) ) ;
54- tempDirs . push ( dir ) ;
52+ const dir = tempDirs . make ( "openclaw-install-policy-windows-" ) ;
5553 const scriptPath = path . join ( dir , "policy.cjs" ) ;
5654 await fs . writeFile ( scriptPath , "export {};\n" , "utf8" ) ;
5755 const unavailablePath = fixture . unavailablePath ( scriptPath ) ;
0 commit comments