mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-16 14:27:26 +00:00
test(cli): whisper install tests hold on Windows hosts
The fake treated only `which` as a lookup, but Windows looks up binaries with `where`. The ensureWhisper cases now run on both hosts on every lane. The init subprocess test also skips when HYPERFRAMES_WHISPER_PATH is set, joins PATH with the platform delimiter and isolates USERPROFILE.
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user