Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

test(e2e): isolate frontmatter-migration through GBRAIN_HOME

Andrei Neacsuc78493b10662
diff --git a/test/e2e/frontmatter-migration.test.ts b/test/e2e/frontmatter-migration.test.ts
index 7be99ea12b..79407a8364 100644
--- a/test/e2e/frontmatter-migration.test.ts
+++ b/test/e2e/frontmatter-migration.test.ts
@@ -42,6 +42,7 @@ let brainRootA: string;
let brainRootB: string;
let engine: PGLiteEngine;
let originalHome: string | undefined;
+let originalGbrainHome: string | undefined;
const originalContents = new Map<string, string>();
beforeAll(async () => {
@@ -90,12 +91,15 @@ beforeAll(async () => {
);
__setTestEngineOverride(engine);
- // Redirect ~/.gbrain/migrations/ output. The orchestrator's gbrainDir()
- // helper reads process.env.HOME at call time, so the override takes
- // effect even though Bun's os.homedir() does not observe mid-process
- // mutations.
+ // Redirect ~/.gbrain/migrations/ output. The orchestrator resolves it via
+ // gbrainPath(): GBRAIN_HOME is a PARENT dir with '.gbrain' appended, so
+ // GBRAIN_HOME=tmpHome routes the audit JSON and pending-host-work to
+ // `tmpHome/.gbrain/migrations/`. HOME moves too so any HOME-based read
+ // stays inside the tmpdir.
originalHome = process.env.HOME;
+ originalGbrainHome = process.env.GBRAIN_HOME;
process.env.HOME = tmpHome;
+ process.env.GBRAIN_HOME = tmpHome;
});
afterAll(async () => {
@@ -103,6 +107,8 @@ afterAll(async () => {
if (engine) await engine.disconnect();
if (originalHome === undefined) delete process.env.HOME;
else process.env.HOME = originalHome;
+ if (originalGbrainHome === undefined) delete process.env.GBRAIN_HOME;
+ else process.env.GBRAIN_HOME = originalGbrainHome;
rmSync(workdir, { recursive: true, force: true });
});