test(installer): isolate install shell snippets · openclaw/openclaw@916ee82
vincentkoc
·
2026-06-01
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -11,8 +11,10 @@ function runInstallShell(script: string, env: NodeJS.ProcessEnv = {}) {
|
11 | 11 | encoding: "utf8", |
12 | 12 | env: { |
13 | 13 | ...process.env, |
14 | | -OPENCLAW_INSTALL_SH_NO_RUN: "1", |
15 | 14 | ...env, |
| 15 | +BASH_ENV: "", |
| 16 | +ENV: "", |
| 17 | +OPENCLAW_INSTALL_SH_NO_RUN: "1", |
16 | 18 | }, |
17 | 19 | }); |
18 | 20 | } |
@@ -88,6 +90,23 @@ function writeNpmBeforePolicyFixture(path: string, argsLog: string) {
|
88 | 90 | describe("install.sh", () => { |
89 | 91 | const script = readFileSync(SCRIPT_PATH, "utf8"); |
90 | 92 | |
| 93 | +it("runs installer snippets without inherited shell startup files", () => { |
| 94 | +const tmp = mkdtempSync(join(tmpdir(), "openclaw-install-shell-env-")); |
| 95 | +const bashEnvPath = join(tmp, "bash_env"); |
| 96 | +writeFileSync(bashEnvPath, "export OPENCLAW_BASH_ENV_LEAKED=1\n"); |
| 97 | + |
| 98 | +try { |
| 99 | +const result = runInstallShell('printf "leaked=%s\\n" "${OPENCLAW_BASH_ENV_LEAKED:-0}"', { |
| 100 | +BASH_ENV: bashEnvPath, |
| 101 | +}); |
| 102 | + |
| 103 | +expect(result.status).toBe(0); |
| 104 | +expect(result.stdout).toBe("leaked=0\n"); |
| 105 | +} finally { |
| 106 | +rmSync(tmp, { force: true, recursive: true }); |
| 107 | +} |
| 108 | +}); |
| 109 | + |
91 | 110 | it("runs apt-get through noninteractive wrappers", () => { |
92 | 111 | expect(script).toContain("apt_get()"); |
93 | 112 | expect(script).toContain('DEBIAN_FRONTEND="${DEBIAN_FRONTEND:-noninteractive}"'); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。