test: avoid windows task-owner tempdir hangs

This commit is contained in:
Peter Steinberger
2026-04-03 09:25:56 +01:00
parent 1849cf71c2
commit 9e47c1a2c5

View File

@@ -21,9 +21,19 @@ afterEach(() => {
async function withTaskRegistryTempDir<T>(run: () => Promise<T> | T): Promise<T> {
return await withTempDir({ prefix: "openclaw-task-owner-access-" }, async (root) => {
const previousStateDir = process.env.OPENCLAW_STATE_DIR;
process.env.OPENCLAW_STATE_DIR = root;
resetTaskRegistryForTests({ persist: false });
return await run();
try {
return await run();
} finally {
resetTaskRegistryForTests({ persist: false });
if (previousStateDir == null) {
delete process.env.OPENCLAW_STATE_DIR;
} else {
process.env.OPENCLAW_STATE_DIR = previousStateDir;
}
}
});
}