1
0

refactor: 引入 Checker 统一接口与 Runner 抽象机制

定义 Checker 接口(resolve/execute/serialize)和 CheckerRegistry
注册中心,消除 engine/config-loader/store 中硬编码类型分支。
按 checker 类型分子包(runner/http/、runner/command/),提取
共享 expect 到 runner/shared/。超时控制通过引擎注入 AbortSignal。
CheckFailure.phase 从联合类型改为 string。配置校验下沉到各
Checker.resolve() 内部。

新增 checker-runner-abstraction spec,更新 DEVELOPMENT.md。
This commit is contained in:
2026-05-12 17:08:57 +08:00
parent e1c33b4002
commit ce8baae3d1
41 changed files with 1493 additions and 1395 deletions

View File

@@ -0,0 +1,25 @@
import { describe, expect, test } from "bun:test";
import { checkExitCode } from "../../../../../src/server/checker/runner/command/expect";
describe("checkExitCode", () => {
test("exitCode 在允许列表中匹配成功", () => {
const r = checkExitCode(0, [0]);
expect(r.matched).toBe(true);
expect(r.failure).toBeNull();
});
test("exitCode 不在允许列表中匹配失败", () => {
const r = checkExitCode(1, [0]);
expect(r.matched).toBe(false);
expect(r.failure!.phase).toBe("exitCode");
expect(r.failure!.kind).toBe("mismatch");
expect(r.failure!.expected).toEqual([0]);
expect(r.failure!.actual).toBe(1);
});
test("多个允许退出码", () => {
expect(checkExitCode(0, [0, 1]).matched).toBe(true);
expect(checkExitCode(1, [0, 1]).matched).toBe(true);
expect(checkExitCode(2, [0, 1]).matched).toBe(false);
});
});