mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-02 23:40:21 +00:00
test: harden threaded shared-worker suites
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { cleanupSessionStateForTest } from "../../src/test-utils/session-state-cleanup.js";
|
||||
|
||||
type EnvValue = string | undefined | ((home: string) => string | undefined);
|
||||
|
||||
@@ -129,6 +130,7 @@ export async function withTempHome<T>(
|
||||
try {
|
||||
return await fn(base);
|
||||
} finally {
|
||||
await cleanupSessionStateForTest().catch(() => undefined);
|
||||
restoreExtraEnv(envSnapshot);
|
||||
restoreEnv(snapshot);
|
||||
try {
|
||||
|
||||
@@ -45,7 +45,10 @@ if (process.getMaxListeners() > 0 && process.getMaxListeners() < TEST_PROCESS_MA
|
||||
|
||||
import { resetContextWindowCacheForTest } from "../src/agents/context.js";
|
||||
import { resetModelsJsonReadyCacheForTest } from "../src/agents/models-config.js";
|
||||
import { resetSessionWriteLockStateForTest } from "../src/agents/session-write-lock.js";
|
||||
import {
|
||||
drainSessionWriteLockStateForTest,
|
||||
resetSessionWriteLockStateForTest,
|
||||
} from "../src/agents/session-write-lock.js";
|
||||
import { createTopLevelChannelReplyToModeResolver } from "../src/channels/plugins/threading-helpers.js";
|
||||
import type {
|
||||
ChannelId,
|
||||
@@ -53,6 +56,7 @@ import type {
|
||||
ChannelPlugin,
|
||||
} from "../src/channels/plugins/types.js";
|
||||
import type { OpenClawConfig } from "../src/config/config.js";
|
||||
import { clearSessionStoreCacheForTest } from "../src/config/sessions/store.js";
|
||||
import { resetFileLockStateForTest } from "../src/infra/file-lock.js";
|
||||
import type { OutboundSendDeps } from "../src/infra/outbound/deliver.js";
|
||||
import { installProcessWarningFilter } from "../src/infra/warning-filter.js";
|
||||
@@ -62,10 +66,6 @@ import { withIsolatedTestHome } from "./test-env.js";
|
||||
// Set HOME/state isolation before importing any runtime OpenClaw modules.
|
||||
const testEnv = withIsolatedTestHome();
|
||||
|
||||
afterAll(() => {
|
||||
testEnv.cleanup();
|
||||
});
|
||||
|
||||
installProcessWarningFilter();
|
||||
|
||||
const REGISTRY_STATE = Symbol.for("openclaw.pluginRegistryState");
|
||||
@@ -355,6 +355,7 @@ beforeAll(() => {
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
clearSessionStoreCacheForTest();
|
||||
resetContextWindowCacheForTest();
|
||||
resetFileLockStateForTest();
|
||||
resetModelsJsonReadyCacheForTest();
|
||||
@@ -366,7 +367,9 @@ afterEach(() => {
|
||||
}
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
afterAll(async () => {
|
||||
clearSessionStoreCacheForTest();
|
||||
await drainSessionWriteLockStateForTest();
|
||||
resetFileLockStateForTest();
|
||||
resetSessionWriteLockStateForTest();
|
||||
testEnv.cleanup();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user