fix(ci): restore cli runtime mocks and timeout exits

This commit is contained in:
Peter Steinberger
2026-03-22 23:43:16 +00:00
parent 85f8437399
commit 4e531d382b
11 changed files with 59 additions and 17 deletions

View File

@@ -28,6 +28,8 @@ vi.mock("../../runtime.js", () => ({
defaultRuntime: {
log: (message: string) => runtimeLogs.push(message),
error: (message: string) => runtimeErrors.push(message),
writeJson: (value: unknown, space = 2) =>
runtimeLogs.push(JSON.stringify(value, null, space > 0 ? space : undefined)),
exit: (code: number) => {
throw new Error(`__exit__:${code}`);
},

View File

@@ -1,13 +1,13 @@
import { vi } from "vitest";
import type { GatewayService } from "../../../daemon/service.js";
import type { RuntimeEnv } from "../../../runtime.js";
import type { OutputRuntimeEnv } from "../../../runtime.js";
import type { MockFn } from "../../../test-utils/vitest-mock-fn.js";
export const runtimeLogs: string[] = [];
type LifecycleRuntimeHarness = RuntimeEnv & {
error: MockFn<RuntimeEnv["error"]>;
exit: MockFn<RuntimeEnv["exit"]>;
type LifecycleRuntimeHarness = OutputRuntimeEnv & {
error: MockFn<OutputRuntimeEnv["error"]>;
exit: MockFn<OutputRuntimeEnv["exit"]>;
};
type LifecycleServiceHarness = GatewayService & {
@@ -24,6 +24,12 @@ export const defaultRuntime: LifecycleRuntimeHarness = {
log: (...args: unknown[]) => {
runtimeLogs.push(args.map((arg) => String(arg)).join(" "));
},
writeStdout: (value: string) => {
runtimeLogs.push(value);
},
writeJson: (value: unknown, space = 2) => {
runtimeLogs.push(JSON.stringify(value, null, space > 0 ? space : undefined));
},
error: vi.fn(),
exit: vi.fn((code: number) => {
throw new Error(`__exit__:${code}`);