fix(test): reject invalid max loc args · openclaw/openclaw@214a28a
vincentkoc
·
2026-06-20
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +// Check Ts Max Loc tests cover CLI argument validation before repository scans. |
| 2 | +import { spawnSync } from "node:child_process"; |
| 3 | +import { describe, expect, it } from "vitest"; |
| 4 | + |
| 5 | +function runCheckTsMaxLoc(args: string[]) { |
| 6 | +return spawnSync(process.execPath, ["--import", "tsx", "scripts/check-ts-max-loc.ts", ...args], { |
| 7 | +cwd: process.cwd(), |
| 8 | +encoding: "utf8", |
| 9 | +}); |
| 10 | +} |
| 11 | + |
| 12 | +describe("scripts/check-ts-max-loc", () => { |
| 13 | +it("rejects unknown options before scanning files", () => { |
| 14 | +const result = runCheckTsMaxLoc(["--unknown"]); |
| 15 | + |
| 16 | +expect(result.status).toBe(1); |
| 17 | +expect(result.stdout).toBe(""); |
| 18 | +expect(result.stderr).toBe("Unknown argument: --unknown\n"); |
| 19 | +}); |
| 20 | + |
| 21 | +it("rejects non-positive max values before scanning files", () => { |
| 22 | +for (const value of ["-1", "0"]) { |
| 23 | +const result = runCheckTsMaxLoc(["--max", value]); |
| 24 | + |
| 25 | +expect(result.status).toBe(1); |
| 26 | +expect(result.stdout).toBe(""); |
| 27 | +expect(result.stderr).toBe("--max requires a positive integer\n"); |
| 28 | +} |
| 29 | +}); |
| 30 | +}); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。