





























@@ -0,0 +1,86 @@
1+import fs from "node:fs";
2+import path from "node:path";
3+import { describe, expect, it } from "vitest";
4+import { getSparseTsgoGuardError } from "../../scripts/lib/tsgo-sparse-guard.mjs";
5+import { createScriptTestHarness } from "./test-helpers.js";
6+7+const { createTempDir } = createScriptTestHarness();
8+9+describe("run-tsgo sparse guard", () => {
10+it("ignores non-core-test projects", () => {
11+const cwd = createTempDir("openclaw-run-tsgo-");
12+13+expect(
14+getSparseTsgoGuardError(["-p", "tsconfig.core.json"], {
15+ cwd,
16+isSparseCheckoutEnabled: () => true,
17+}),
18+).toBeNull();
19+});
20+21+it("ignores full worktrees", () => {
22+const cwd = createTempDir("openclaw-run-tsgo-");
23+24+expect(
25+getSparseTsgoGuardError(["-p", "tsconfig.core.test.json"], {
26+ cwd,
27+isSparseCheckoutEnabled: () => false,
28+}),
29+).toBeNull();
30+});
31+32+it("ignores metadata-only commands", () => {
33+const cwd = createTempDir("openclaw-run-tsgo-");
34+35+expect(
36+getSparseTsgoGuardError(["-p", "tsconfig.core.test.json", "--showConfig"], {
37+ cwd,
38+isSparseCheckoutEnabled: () => true,
39+}),
40+).toBeNull();
41+});
42+43+it("ignores sparse worktrees when the required files are present", () => {
44+const cwd = createTempDir("openclaw-run-tsgo-");
45+const requiredPaths = [
46+"packages/plugin-package-contract/src/index.ts",
47+"ui/src/i18n/lib/registry.ts",
48+"ui/src/i18n/lib/types.ts",
49+"ui/src/ui/app-settings.ts",
50+"ui/src/ui/gateway.ts",
51+];
52+53+for (const relativePath of requiredPaths) {
54+const absolutePath = path.join(cwd, relativePath);
55+const dir = path.dirname(absolutePath);
56+fs.mkdirSync(dir, { recursive: true });
57+fs.writeFileSync(absolutePath, "", "utf8");
58+}
59+60+expect(
61+getSparseTsgoGuardError(["-p", "tsconfig.core.test.non-agents.json"], {
62+ cwd,
63+isSparseCheckoutEnabled: () => true,
64+}),
65+).toBeNull();
66+});
67+68+it("returns a helpful message for sparse core-test worktrees missing ui and packages files", () => {
69+const cwd = createTempDir("openclaw-run-tsgo-");
70+71+expect(
72+getSparseTsgoGuardError(["-p", "tsconfig.core.test.json"], {
73+ cwd,
74+isSparseCheckoutEnabled: () => true,
75+}),
76+).toMatchInlineSnapshot(`
77+ "tsconfig.core.test.json requires a full worktree, but this checkout is sparse and missing files that the core test graph imports:
78+ - packages/plugin-package-contract/src/index.ts
79+ - ui/src/i18n/lib/registry.ts
80+ - ui/src/i18n/lib/types.ts
81+ - ui/src/ui/app-settings.ts
82+ - ui/src/ui/gateway.ts
83+ Run "gwt sparse full" in this worktree, then rerun the tsgo command."
84+ `);
85+});
86+});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。