mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-29 05:02:04 +03:00
test(docker): make bash 3.2 compatibility check portable
This commit is contained in:
@@ -73,6 +73,17 @@ function createEnv(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function resolveBashForCompatCheck(): string | null {
|
||||||
|
for (const candidate of ["/bin/bash", "bash"]) {
|
||||||
|
const probe = spawnSync(candidate, ["-c", "exit 0"], { encoding: "utf8" });
|
||||||
|
if (!probe.error && probe.status === 0) {
|
||||||
|
return candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
describe("docker-setup.sh", () => {
|
describe("docker-setup.sh", () => {
|
||||||
it("handles unset optional env vars under strict mode", async () => {
|
it("handles unset optional env vars under strict mode", async () => {
|
||||||
const sandbox = await createDockerSetupSandbox();
|
const sandbox = await createDockerSetupSandbox();
|
||||||
@@ -121,11 +132,15 @@ describe("docker-setup.sh", () => {
|
|||||||
const script = await readFile(join(repoRoot, "docker-setup.sh"), "utf8");
|
const script = await readFile(join(repoRoot, "docker-setup.sh"), "utf8");
|
||||||
expect(script).not.toMatch(/^\s*declare -A\b/m);
|
expect(script).not.toMatch(/^\s*declare -A\b/m);
|
||||||
|
|
||||||
const systemBash = "/bin/bash";
|
const systemBash = resolveBashForCompatCheck();
|
||||||
|
if (!systemBash) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const assocCheck = spawnSync(systemBash, ["-c", "declare -A _t=()"], {
|
const assocCheck = spawnSync(systemBash, ["-c", "declare -A _t=()"], {
|
||||||
encoding: "utf8",
|
encoding: "utf8",
|
||||||
});
|
});
|
||||||
if (assocCheck.status === 0) {
|
if (assocCheck.status === null || assocCheck.status === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user