mirror of
https://github.com/heygen-com/hyperframes.git
synced 2026-11-18 07:50:13 +00:00
* fix(cli): check stops making video copies after 10 minutes, and --timeout takes units The copy phase of check had no overall limit: a source that kept moving was never stopped, and stdout stays silent the whole time. It now ends after 10 minutes with an error naming the files still unfinished and the elapsed seconds; finished copies are reused on the next run. The stderr progress lines are unchanged. --timeout on check and snapshot is milliseconds, so "--timeout 45" waited 45 ms. It now accepts 45s, 2m and 45000ms, and a bare number under 1000 warns on stderr that it is milliseconds. Output on stdout is unchanged. * chore(cli): cut the --timeout parser comment to the comment limit * fix(cli): drop the 10 minute wall clock on check's video copies A copy that keeps making progress must not be cut by a clock, and a re-run would only start it over. The copy already ends when ffmpeg stops reporting progress for 3 minutes (finished pieces are kept for the next run), so the phase is bounded on no progress. The --timeout warning now names the value actually used when check raises a small value to its 500 ms floor.
46 lines
1.8 KiB
TypeScript
46 lines
1.8 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import { parseTimeoutMs } from "./timeoutArg.js";
|
|
|
|
describe("parseTimeoutMs", () => {
|
|
it("reads a bare number as milliseconds and units as written", () => {
|
|
const warn = vi.fn();
|
|
expect(parseTimeoutMs("45000", 3000, 0, warn)).toBe(45_000);
|
|
expect(parseTimeoutMs("45000ms", 3000, 0, warn)).toBe(45_000);
|
|
expect(parseTimeoutMs("45s", 3000, 0, warn)).toBe(45_000);
|
|
expect(parseTimeoutMs("2m", 3000, 0, warn)).toBe(120_000);
|
|
expect(parseTimeoutMs("1.5s", 3000, 0, warn)).toBe(1_500);
|
|
expect(warn).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("falls back when absent, zero or not a duration", () => {
|
|
const warn = vi.fn();
|
|
expect(parseTimeoutMs(undefined, 3000, 0, warn)).toBe(3000);
|
|
expect(parseTimeoutMs("0", 3000, 0, warn)).toBe(3000);
|
|
expect(parseTimeoutMs("soon", 3000, 0, warn)).toBe(3000);
|
|
expect(warn).toHaveBeenCalledTimes(1);
|
|
expect(warn.mock.calls[0]![0]).toContain('"soon"');
|
|
});
|
|
|
|
it("warns that a bare value under 1000 is milliseconds, and keeps it", () => {
|
|
const warn = vi.fn();
|
|
expect(parseTimeoutMs("45", 3000, 0, warn)).toBe(45);
|
|
expect(warn).toHaveBeenCalledTimes(1);
|
|
expect(warn.mock.calls[0]![0]).toContain("45 ms");
|
|
expect(warn.mock.calls[0]![0]).toContain("45s");
|
|
});
|
|
|
|
it("names the value actually used when the floor raises it", () => {
|
|
const warn = vi.fn();
|
|
expect(parseTimeoutMs("45", 3000, 500, warn)).toBe(500);
|
|
expect(warn.mock.calls[0]![0]).toContain("so 500 ms is used");
|
|
expect(parseTimeoutMs("200ms", 3000, 500, warn)).toBe(500);
|
|
expect(warn).toHaveBeenCalledTimes(1);
|
|
});
|
|
|
|
it("does not warn when a unit is given, even for a small value", () => {
|
|
const warn = vi.fn();
|
|
expect(parseTimeoutMs("500ms", 3000, 0, warn)).toBe(500);
|
|
expect(warn).not.toHaveBeenCalled();
|
|
});
|
|
});
|