From 7bd6bb91c46b9561024d927a604e99bee2666e4d Mon Sep 17 00:00:00 2001 From: Shakker Date: Wed, 1 Apr 2026 14:45:54 +0100 Subject: [PATCH] fix: trim non-live test setup work --- .gitignore | 1 + test/test-env.test.ts | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/.gitignore b/.gitignore index 9c3ff9369e9..3f3ecf24fe2 100644 --- a/.gitignore +++ b/.gitignore @@ -142,3 +142,4 @@ changelog/fragments/ # Local scratch workspace .tmp/ test/fixtures/openclaw-vitest-unit-report.json +analysis/ diff --git a/test/test-env.test.ts b/test/test-env.test.ts index bc073931b7a..e76bc539c6b 100644 --- a/test/test-env.test.ts +++ b/test/test-env.test.ts @@ -141,6 +141,25 @@ describe("installTestEnv", () => { expect(process.env.TEST_PROFILE_ONLY).toBe("from-profile"); }); + it("does not load ~/.profile for normal isolated test runs", () => { + const realHome = createTempHome(); + writeFile(path.join(realHome, ".profile"), "export TEST_PROFILE_ONLY=from-profile\n"); + + process.env.HOME = realHome; + process.env.USERPROFILE = realHome; + delete process.env.LIVE; + delete process.env.OPENCLAW_LIVE_TEST; + delete process.env.OPENCLAW_LIVE_GATEWAY; + delete process.env.OPENCLAW_LIVE_USE_REAL_HOME; + delete process.env.OPENCLAW_LIVE_TEST_QUIET; + + const testEnv = installTestEnv(); + cleanupFns.push(testEnv.cleanup); + + expect(testEnv.tempHome).not.toBe(realHome); + expect(process.env.TEST_PROFILE_ONLY).toBeUndefined(); + }); + it("falls back to parsing ~/.profile when bash is unavailable", async () => { const realHome = createTempHome(); writeFile(path.join(realHome, ".profile"), "export TEST_PROFILE_ONLY=from-profile\n");