diff --git a/packages/cli/src/commands/init.test.ts b/packages/cli/src/commands/init.test.ts index c350d7bfd1..079cc6e631 100644 --- a/packages/cli/src/commands/init.test.ts +++ b/packages/cli/src/commands/init.test.ts @@ -11,7 +11,7 @@ import { writeFileSync, } from "node:fs"; import { tmpdir } from "node:os"; -import { join, resolve } from "node:path"; +import { delimiter, join, resolve } from "node:path"; import { fileURLToPath } from "node:url"; import { applyResolutionPreset, @@ -295,6 +295,7 @@ describe("hyperframes init flag rename", () => { }); const whisperOnMachine = + Boolean(process.env.HYPERFRAMES_WHISPER_PATH) || spawnSync("which", ["whisper-cli"]).status === 0 || ["/opt/homebrew/bin/whisper-cli", "/usr/local/bin/whisper-cli"].some((p) => existsSync(p)); @@ -313,10 +314,12 @@ describe("hyperframes init flag rename", () => { // A fresh HOME hides any whisper built into ~/.cache by an earlier run. const res = runInit([join(dir, "proj"), "--non-interactive", "--audio", audio], { HOME: dir, - PATH: `${bin}:${process.env.PATH}`, + USERPROFILE: dir, + PATH: `${bin}${delimiter}${process.env.PATH}`, }); expect(res.stdout).toContain("hyperframes models install parakeet"); - expect(existsSync(installLog)).toBe(false); + // The fakes are sh scripts, which Windows cannot run. + if (process.platform !== "win32") expect(existsSync(installLog)).toBe(false); } finally { rmSync(dir, { recursive: true, force: true }); } diff --git a/packages/cli/src/whisper/manager-resolution.test.ts b/packages/cli/src/whisper/manager-resolution.test.ts index 4063c6e989..42e184e522 100644 --- a/packages/cli/src/whisper/manager-resolution.test.ts +++ b/packages/cli/src/whisper/manager-resolution.test.ts @@ -1,6 +1,6 @@ -import { beforeEach, describe, expect, it, vi } from "vitest"; +import { afterAll, beforeEach, describe, expect, it, vi } from "vitest"; -// brew, git and cmake are on PATH; every non-`which` command is recorded as an install attempt. +// brew, git and cmake are on PATH; any command but a which/where lookup counts as an install. const state = vi.hoisted(() => ({ attended: false, installs: [] as string[] })); vi.mock("node:child_process", async (importOriginal) => { @@ -8,7 +8,7 @@ vi.mock("node:child_process", async (importOriginal) => { return { ...actual, execFileSync: vi.fn((command: string, args: string[]) => { - if (command === "which") { + if (command === "which" || command === "where") { if (args[0] === "whisper") return "/fake/python-whisper\n"; if (["brew", "git", "cmake"].includes(args[0] ?? "")) return `/fake/${args[0]}\n`; throw new Error(`${args[0]} not found`); @@ -39,7 +39,9 @@ describe("findWhisper", () => { }); }); -describe("ensureWhisper", () => { +// Lookups run `where` when process.platform is win32, so cover both hosts on every CI lane. +describe.each(["linux", "win32"])("ensureWhisper on a %s host", (hostPlatform) => { + const realPlatform = process.platform; const unattendedError = { code: "WHISPER_UNAVAILABLE", message: expect.stringMatching(/hyperframes models install parakeet.*brew install whisper-cpp/), @@ -47,6 +49,11 @@ describe("ensureWhisper", () => { beforeEach(() => { state.installs.length = 0; + Object.defineProperty(process, "platform", { value: hostPlatform }); + }); + + afterAll(() => { + Object.defineProperty(process, "platform", { value: realPlatform }); }); it("an unattended run only probes: no brew, no source build", async () => {