fix(testing): route command root target to both shards · openclaw/openclaw@023ce6e
vincentkoc
·
2026-06-17
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1024,6 +1024,14 @@ function isExistingFileTarget(arg, cwd) {
|
1024 | 1024 | } |
1025 | 1025 | } |
1026 | 1026 | |
| 1027 | +function isExistingDirectoryTarget(arg, cwd) { |
| 1028 | +try { |
| 1029 | +return fs.statSync(path.resolve(cwd, arg)).isDirectory(); |
| 1030 | +} catch { |
| 1031 | +return false; |
| 1032 | +} |
| 1033 | +} |
| 1034 | + |
1027 | 1035 | function isGlobTarget(arg) { |
1028 | 1036 | return /[*?[\]{}]/u.test(arg); |
1029 | 1037 | } |
@@ -1166,6 +1174,10 @@ function expandExplicitSourceTestTargets(targetArgs, cwd) {
|
1166 | 1174 | }).length; |
1167 | 1175 | const forceFullImportGraph = sourceTargetCount > EXPLICIT_SOURCE_FULL_IMPORT_GRAPH_THRESHOLD; |
1168 | 1176 | return targetArgs.flatMap((targetArg) => { |
| 1177 | +const relative = toRepoRelativeTarget(targetArg, cwd); |
| 1178 | +if (relative === "src/commands" && isExistingDirectoryTarget(targetArg, cwd)) { |
| 1179 | +return [COMMANDS_LIGHT_VITEST_CONFIG, COMMANDS_VITEST_CONFIG]; |
| 1180 | +} |
1169 | 1181 | const targets = resolveExplicitSourceTestTargets(targetArg, cwd, { |
1170 | 1182 | forceFullImportGraph, |
1171 | 1183 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1728,6 +1728,24 @@ describe("scripts/test-projects changed-target routing", () => {
|
1728 | 1728 | ]); |
1729 | 1729 | }); |
1730 | 1730 | |
| 1731 | +it("routes the full commands test root to both command shards", () => { |
| 1732 | +expect(findUnmatchedExplicitTestTargets(["src/commands"])).toEqual([]); |
| 1733 | +expect(buildVitestRunPlans(["src/commands"], process.cwd())).toEqual([ |
| 1734 | +{ |
| 1735 | +config: "test/vitest/vitest.commands-light.config.ts", |
| 1736 | +forwardedArgs: [], |
| 1737 | +includePatterns: null, |
| 1738 | +watchMode: false, |
| 1739 | +}, |
| 1740 | +{ |
| 1741 | +config: "test/vitest/vitest.commands.config.ts", |
| 1742 | +forwardedArgs: [], |
| 1743 | +includePatterns: null, |
| 1744 | +watchMode: false, |
| 1745 | +}, |
| 1746 | +]); |
| 1747 | +}); |
| 1748 | + |
1731 | 1749 | it("routes unit-fast light tests to the cache-friendly unit-fast lane", () => { |
1732 | 1750 | const plans = buildVitestRunPlans( |
1733 | 1751 | ["src/commands/status-overview-values.test.ts"], |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。