ESLint 升级到 recommended-type-checked + stylistic-type-checked, 引入 perfectionist 导入排序和 import 插件导入验证。 Prettier 显式声明全部格式化参数,消除跨环境差异。 TypeScript 启用 noUnusedLocals 和 noPropertyAccessFromIndexSignature。 完善 ignore 列表,排除 .agents/、bun.lock、data/ 等。 引入 husky + lint-staged(pre-commit)+ commitlint(commit-msg)。 更新 DEVELOPMENT.md 代码质量章节。 修复所有新增规则检测到的类型和风格违规。
27 lines
886 B
TypeScript
27 lines
886 B
TypeScript
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);
|
|
});
|
|
});
|