From 916ee82814e75330ed760f6d53fd014faafead65 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Mon, 1 Jun 2026 04:06:11 +0100 Subject: [PATCH] test(installer): isolate install shell snippets --- test/scripts/install-sh.test.ts | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/test/scripts/install-sh.test.ts b/test/scripts/install-sh.test.ts index 394ddf111afe..00df59048fe2 100644 --- a/test/scripts/install-sh.test.ts +++ b/test/scripts/install-sh.test.ts @@ -11,8 +11,10 @@ function runInstallShell(script: string, env: NodeJS.ProcessEnv = {}) { encoding: "utf8", env: { ...process.env, - OPENCLAW_INSTALL_SH_NO_RUN: "1", ...env, + BASH_ENV: "", + ENV: "", + OPENCLAW_INSTALL_SH_NO_RUN: "1", }, }); } @@ -88,6 +90,23 @@ function writeNpmBeforePolicyFixture(path: string, argsLog: string) { describe("install.sh", () => { const script = readFileSync(SCRIPT_PATH, "utf8"); + it("runs installer snippets without inherited shell startup files", () => { + const tmp = mkdtempSync(join(tmpdir(), "openclaw-install-shell-env-")); + const bashEnvPath = join(tmp, "bash_env"); + writeFileSync(bashEnvPath, "export OPENCLAW_BASH_ENV_LEAKED=1\n"); + + try { + const result = runInstallShell('printf "leaked=%s\\n" "${OPENCLAW_BASH_ENV_LEAKED:-0}"', { + BASH_ENV: bashEnvPath, + }); + + expect(result.status).toBe(0); + expect(result.stdout).toBe("leaked=0\n"); + } finally { + rmSync(tmp, { force: true, recursive: true }); + } + }); + it("runs apt-get through noninteractive wrappers", () => { expect(script).toContain("apt_get()"); expect(script).toContain('DEBIAN_FRONTEND="${DEBIAN_FRONTEND:-noninteractive}"');