test(commands): skip temp home cleanup in agent suite

This commit is contained in:
Peter Steinberger
2026-05-06 21:25:48 +01:00
parent 0f9f956bbd
commit 3baf4de2cf
2 changed files with 23 additions and 16 deletions

View File

@@ -234,7 +234,11 @@ vi.mock("../config/sessions/transcript-resolve.runtime.js", () => {
const runtime = createThrowingTestRuntime();
async function withTempHome<T>(fn: (home: string) => Promise<T>): Promise<T> {
return withTempHomeBase(fn, { prefix: "openclaw-agent-", skipSessionCleanup: true });
return withTempHomeBase(fn, {
prefix: "openclaw-agent-",
skipHomeCleanup: true,
skipSessionCleanup: true,
});
}
function mockConfig(

View File

@@ -104,6 +104,7 @@ export async function withTempHome<T>(
opts: {
env?: Record<string, EnvValue>;
prefix?: string;
skipHomeCleanup?: boolean;
skipSessionCleanup?: boolean;
} = {},
): Promise<T> {
@@ -139,22 +140,24 @@ export async function withTempHome<T>(
}
restoreExtraEnv(envSnapshot);
restoreEnv(snapshot);
try {
if (process.platform === "win32") {
await fs.rm(base, {
recursive: true,
force: true,
maxRetries: 10,
retryDelay: 50,
});
} else {
await fs.rm(base, {
recursive: true,
force: true,
});
if (!opts.skipHomeCleanup) {
try {
if (process.platform === "win32") {
await fs.rm(base, {
recursive: true,
force: true,
maxRetries: 10,
retryDelay: 50,
});
} else {
await fs.rm(base, {
recursive: true,
force: true,
});
}
} catch {
// ignore cleanup failures in tests
}
} catch {
// ignore cleanup failures in tests
}
}
}