Better tests and more user feedback while doing transcription; WIP.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { describe, test, expect } from "bun:test";
|
||||
import {
|
||||
applyLoadProgress,
|
||||
deviceAttempts,
|
||||
initialLoadProgress,
|
||||
isUiToWorkerMessage,
|
||||
isWorkerToUiMessage,
|
||||
@@ -103,6 +104,57 @@ describe("isWorkerToUiMessage", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("deviceAttempts (D-004, D-017)", () => {
|
||||
test("auto resolves WebNN → WebGPU → WASM when everything is available", () => {
|
||||
expect(deviceAttempts("auto", { webnn: true, webgpu: true })).toEqual([
|
||||
"webnn",
|
||||
"webgpu",
|
||||
"wasm",
|
||||
]);
|
||||
});
|
||||
|
||||
test("auto skips backends the probe ruled out, in order", () => {
|
||||
expect(deviceAttempts("auto", { webnn: false, webgpu: true })).toEqual([
|
||||
"webgpu",
|
||||
"wasm",
|
||||
]);
|
||||
expect(deviceAttempts("auto", { webnn: true, webgpu: false })).toEqual([
|
||||
"webnn",
|
||||
"wasm",
|
||||
]);
|
||||
expect(deviceAttempts("auto", { webnn: false, webgpu: false })).toEqual(["wasm"]);
|
||||
});
|
||||
|
||||
test("explicit webgpu falls back to WASM only", () => {
|
||||
expect(deviceAttempts("webgpu", { webnn: true, webgpu: true })).toEqual([
|
||||
"webgpu",
|
||||
"wasm",
|
||||
]);
|
||||
expect(deviceAttempts("webgpu", { webnn: true, webgpu: false })).toEqual(["wasm"]);
|
||||
});
|
||||
|
||||
test("explicit webnn falls back to WASM only (no WebGPU detour)", () => {
|
||||
expect(deviceAttempts("webnn", { webnn: true, webgpu: true })).toEqual([
|
||||
"webnn",
|
||||
"wasm",
|
||||
]);
|
||||
expect(deviceAttempts("webnn", { webnn: false, webgpu: true })).toEqual(["wasm"]);
|
||||
});
|
||||
|
||||
test("wasm is honored as-is and every chain ends in WASM", () => {
|
||||
expect(deviceAttempts("wasm", { webnn: true, webgpu: true })).toEqual(["wasm"]);
|
||||
for (const preference of ["auto", "webnn", "webgpu", "wasm"] as const) {
|
||||
for (const webnn of [true, false]) {
|
||||
for (const webgpu of [true, false]) {
|
||||
const attempts = deviceAttempts(preference, { webnn, webgpu });
|
||||
expect(attempts.length).toBeGreaterThan(0);
|
||||
expect(attempts.at(-1)).toBe("wasm");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe("applyLoadProgress", () => {
|
||||
test("tracks per-file byte progress without mutating previous state", () => {
|
||||
const p1: LoadProgressMessage = { type: "load-progress", status: "initiate", file: "a.onnx" };
|
||||
|
||||
Reference in New Issue
Block a user