11// Plugin registry loader tests cover CLI plugin registry loading and cache reset behavior.
2- import { mkdtemp , readFile , rm } from "node:fs/promises" ;
3- import { tmpdir } from "node:os" ;
2+ import { readFile } from "node:fs/promises" ;
43import { join } from "node:path" ;
54import { afterEach , beforeAll , beforeEach , describe , expect , it , vi } from "vitest" ;
5+ import { useAutoCleanupTempDirTracker } from "../../test/helpers/temp-dir.js" ;
66import { measureCliCommandStartup } from "./command-startup-timing.js" ;
77
88const ensurePluginRegistryLoadedMock = vi . hoisted ( ( ) => vi . fn ( ) ) ;
9- const tempDirs : string [ ] = [ ] ;
9+ const tempDirs = useAutoCleanupTempDirTracker ( afterEach ) ;
1010
1111vi . mock ( "./plugin-registry.js" , ( ) => ( {
1212 ensurePluginRegistryLoaded : ensurePluginRegistryLoadedMock ,
@@ -28,10 +28,9 @@ describe("plugin-registry-loader", () => {
2828 loggingState . forceConsoleToStderr = false ;
2929 } ) ;
3030
31- afterEach ( async ( ) => {
31+ afterEach ( ( ) => {
3232 loggingState . forceConsoleToStderr = originalForceStderr ;
3333 vi . unstubAllEnvs ( ) ;
34- await Promise . all ( tempDirs . splice ( 0 ) . map ( ( dir ) => rm ( dir , { recursive : true , force : true } ) ) ) ;
3534 } ) ;
3635
3736 it ( "routes plugin load logs to stderr and restores state" , async ( ) => {
@@ -94,8 +93,7 @@ describe("plugin-registry-loader", () => {
9493 } ) ;
9594
9695 it ( "attributes module import separately from runtime loading" , async ( ) => {
97- const dir = await mkdtemp ( join ( tmpdir ( ) , "openclaw-plugin-registry-startup-" ) ) ;
98- tempDirs . push ( dir ) ;
96+ const dir = tempDirs . make ( "openclaw-plugin-registry-startup-" ) ;
9997 const timelinePath = join ( dir , "timeline.jsonl" ) ;
10098 vi . stubEnv ( "OPENCLAW_DIAGNOSTICS" , "timeline" ) ;
10199 vi . stubEnv ( "OPENCLAW_DIAGNOSTICS_TIMELINE_PATH" , timelinePath ) ;
0 commit comments