mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 08:41:23 +00:00
test: make brew fallback assertion windows-safe
This commit is contained in:
committed by
Peter Steinberger
parent
6c813bd32b
commit
69cedc7a15
@@ -63,18 +63,25 @@ describe("brew helpers", () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it("falls back to prefix when HOMEBREW_BREW_FILE is not executable", async () => {
|
it("falls back to prefix when HOMEBREW_BREW_FILE is missing or not executable", async () => {
|
||||||
await withBrewRoot(async (tmp) => {
|
await withBrewRoot(async (tmp) => {
|
||||||
const explicit = path.join(tmp, "custom", "brew");
|
const explicit = path.join(tmp, "custom", "brew");
|
||||||
const prefix = path.join(tmp, "prefix");
|
const prefix = path.join(tmp, "prefix");
|
||||||
const prefixBrew = path.join(prefix, "bin", "brew");
|
const prefixBrew = path.join(prefix, "bin", "brew");
|
||||||
await fs.mkdir(path.dirname(explicit), { recursive: true });
|
let brewFile = explicit;
|
||||||
await fs.writeFile(explicit, "#!/bin/sh\necho no\n", "utf-8");
|
if (process.platform === "win32") {
|
||||||
await fs.chmod(explicit, 0o644);
|
// Windows doesn't enforce POSIX executable bits, so use a missing path
|
||||||
|
// to verify fallback behavior deterministically.
|
||||||
|
brewFile = path.join(tmp, "custom", "missing-brew");
|
||||||
|
} else {
|
||||||
|
await fs.mkdir(path.dirname(explicit), { recursive: true });
|
||||||
|
await fs.writeFile(explicit, "#!/bin/sh\necho no\n", "utf-8");
|
||||||
|
await fs.chmod(explicit, 0o644);
|
||||||
|
}
|
||||||
await writeExecutable(prefixBrew);
|
await writeExecutable(prefixBrew);
|
||||||
|
|
||||||
const env: NodeJS.ProcessEnv = {
|
const env: NodeJS.ProcessEnv = {
|
||||||
HOMEBREW_BREW_FILE: explicit,
|
HOMEBREW_BREW_FILE: brewFile,
|
||||||
HOMEBREW_PREFIX: prefix,
|
HOMEBREW_PREFIX: prefix,
|
||||||
};
|
};
|
||||||
expect(resolveBrewExecutable({ homeDir: tmp, env })).toBe(prefixBrew);
|
expect(resolveBrewExecutable({ homeDir: tmp, env })).toBe(prefixBrew);
|
||||||
|
|||||||
Reference in New Issue
Block a user