forked from mtusi2026/mtusi2026lab7
56 lines
3.1 KiB
Plaintext
56 lines
3.1 KiB
Plaintext
bun test v1.4.4 (38afee6c8)
|
|
|
|
student-tests/runtime-preparation.test.ts:
|
|
(pass) canonical runtime invokes its build exactly once [0.21ms]
|
|
7 | throw new Error("RUNTIME_PREPARATION_PORTS_REQUIRED");
|
|
8 | return async (mode: RuntimeMode) => {
|
|
9 | if (mode !== "canonical" && mode !== "checked-cache")
|
|
10 | throw new Error("INVALID_RUNTIME_MODE");
|
|
11 | if (mode === "canonical") await ports.build();
|
|
12 | else throw new Error("CHECKED_RUNTIME_NOT_IMPLEMENTED");
|
|
^
|
|
error: CHECKED_RUNTIME_NOT_IMPLEMENTED
|
|
at <anonymous> (/Users/rey/mtuci/vp/lab7/scripts/runtime-preparation.ts:12:20)
|
|
at <anonymous> (/Users/rey/mtuci/vp/lab7/student-tests/runtime-preparation.test.ts:7:140)
|
|
(fail) checked cache verifies existing runtime without an implicit build [0.14ms]
|
|
7 | const calls:string[]=[];await createRuntimePreparation({build:async()=>{calls.push("build");},verifyCache:async()=>{calls.push("cache");}})("checked-cache");expect(calls).toEqual(["cache"]);
|
|
8 | });
|
|
9 | test("failed cache verification preserves its error and never falls back to a build",async()=>{
|
|
10 | const error=new Error("FIXTURE_WRONG_BINARY"),calls:string[]=[];let observed:unknown;
|
|
11 | try{await createRuntimePreparation({build:async()=>{calls.push("build");},verifyCache:async()=>{calls.push("cache");throw error;}})("checked-cache");}catch(e){observed=e;}
|
|
12 | expect(observed).toBe(error);expect(calls).toEqual(["cache"]);
|
|
^
|
|
error: expect(received).toBe(expected)
|
|
|
|
Expected: 5 | });
|
|
6 | test("checked cache verifies existing runtime without an implicit build",async()=>{
|
|
7 | const calls:string[]=[];await createRuntimePreparation({build:async()=>{calls.push("build");},verifyCache:async()=>{calls.push("cache");}})("checked-cache");expect(calls).toEqual(["cache"]);
|
|
8 | });
|
|
9 | test("failed cache verification preserves its error and never falls back to a build",async()=>{
|
|
10 | const error=new Error("FIXTURE_WRONG_BINARY"),calls:string[]=[];let observed:unknown;
|
|
^
|
|
error: FIXTURE_WRONG_BINARY
|
|
at <anonymous> (/Users/rey/mtuci/vp/lab7/student-tests/runtime-preparation.test.ts:10:18)
|
|
|
|
Received: 7 | throw new Error("RUNTIME_PREPARATION_PORTS_REQUIRED");
|
|
8 | return async (mode: RuntimeMode) => {
|
|
9 | if (mode !== "canonical" && mode !== "checked-cache")
|
|
10 | throw new Error("INVALID_RUNTIME_MODE");
|
|
11 | if (mode === "canonical") await ports.build();
|
|
12 | else throw new Error("CHECKED_RUNTIME_NOT_IMPLEMENTED");
|
|
^
|
|
error: CHECKED_RUNTIME_NOT_IMPLEMENTED
|
|
at <anonymous> (/Users/rey/mtuci/vp/lab7/scripts/runtime-preparation.ts:12:20)
|
|
at <anonymous> (/Users/rey/mtuci/vp/lab7/student-tests/runtime-preparation.test.ts:11:132)
|
|
|
|
|
|
at <anonymous> (/Users/rey/mtuci/vp/lab7/student-tests/runtime-preparation.test.ts:12:19)
|
|
(fail) failed cache verification preserves its error and never falls back to a build [0.15ms]
|
|
(pass) unknown runtime mode fails before either operational port [0.04ms]
|
|
(pass) constructor requires both explicit ports [0.02ms]
|
|
|
|
3 pass
|
|
2 fail
|
|
5 expect() calls
|
|
Ran 5 tests across 1 file. [7.00ms]
|