mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 05:16:23 -06:00
test(installer): isolate install shell snippets
This commit is contained in:
@@ -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}"');
|
||||
|
||||
Reference in New Issue
Block a user