From ce0eddd3849bdf8981f7116e9bf119093181284e Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 14 Feb 2026 13:27:03 +0000 Subject: [PATCH] test: isolate test home before runtime imports --- test/setup.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/test/setup.ts b/test/setup.ts index f9f4d3ff74..bb400a31e8 100644 --- a/test/setup.ts +++ b/test/setup.ts @@ -16,15 +16,21 @@ import type { } from "../src/channels/plugins/types.js"; import type { OpenClawConfig } from "../src/config/config.js"; import type { OutboundSendDeps } from "../src/infra/outbound/deliver.js"; -import { installProcessWarningFilter } from "../src/infra/warning-filter.js"; -import { setActivePluginRegistry } from "../src/plugins/runtime.js"; -import { createTestRegistry } from "../src/test-utils/channel-plugins.js"; import { withIsolatedTestHome } from "./test-env.js"; +// Set HOME/state isolation before importing any runtime OpenClaw modules. +const testEnv = withIsolatedTestHome(); +afterAll(() => testEnv.cleanup()); + +const [{ installProcessWarningFilter }, { setActivePluginRegistry }, { createTestRegistry }] = + await Promise.all([ + import("../src/infra/warning-filter.js"), + import("../src/plugins/runtime.js"), + import("../src/test-utils/channel-plugins.js"), + ]); + installProcessWarningFilter(); -const testEnv = withIsolatedTestHome(); -afterAll(() => testEnv.cleanup()); const pickSendFn = (id: ChannelId, deps?: OutboundSendDeps) => { switch (id) { case "discord":