test: tighten brew helper coverage

This commit is contained in:
Peter Steinberger 2026-03-13 23:47:22 +00:00
parent 3b9989bd90
commit fffe587e27
1 changed files with 29 additions and 0 deletions

View File

@ -88,6 +88,35 @@ describe("brew helpers", () => {
});
});
it("ignores blank HOMEBREW_BREW_FILE and HOMEBREW_PREFIX values", async () => {
await withBrewRoot(async (tmp) => {
const homebrewBin = path.join(tmp, ".linuxbrew", "bin");
const brewPath = path.join(homebrewBin, "brew");
await writeExecutable(brewPath);
const env: NodeJS.ProcessEnv = {
HOMEBREW_BREW_FILE: " ",
HOMEBREW_PREFIX: "\t",
};
expect(resolveBrewExecutable({ homeDir: tmp, env })).toBe(brewPath);
const dirs = resolveBrewPathDirs({ homeDir: tmp, env });
expect(dirs).not.toContain(path.join("", "bin"));
expect(dirs).not.toContain(path.join("", "sbin"));
});
});
it("always includes the standard macOS brew dirs after linuxbrew candidates", () => {
const env: NodeJS.ProcessEnv = {
HOMEBREW_BREW_FILE: " ",
HOMEBREW_PREFIX: " ",
};
const dirs = resolveBrewPathDirs({ homeDir: "/home/test", env });
expect(dirs.slice(-2)).toEqual(["/opt/homebrew/bin", "/usr/local/bin"]);
});
it("includes Linuxbrew bin/sbin in path candidates", () => {
const env: NodeJS.ProcessEnv = { HOMEBREW_PREFIX: "/custom/prefix" };
const dirs = resolveBrewPathDirs({ homeDir: "/home/test", env });