mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
test: explain skipped changed vitest targets
This commit is contained in:
@@ -30,6 +30,7 @@ import {
|
||||
orderFullSuiteSpecsForParallelRun,
|
||||
parseTestProjectsArgs,
|
||||
resolveParallelFullSuiteConcurrency,
|
||||
resolveChangedTestTargetPlanForArgs,
|
||||
resolveChangedTargetArgs,
|
||||
shouldAcquireLocalHeavyCheckLock,
|
||||
shouldRetryVitestNoOutputTimeout,
|
||||
@@ -169,6 +170,26 @@ function isFullExtensionsProjectRun(specs) {
|
||||
);
|
||||
}
|
||||
|
||||
function printNoChangedTestTargets(args, cwd, baseEnv) {
|
||||
const plan = resolveChangedTestTargetPlanForArgs(args, cwd, undefined, { env: baseEnv });
|
||||
const skippedBroadFallbackPaths = plan?.skippedBroadFallbackPaths ?? [];
|
||||
if (skippedBroadFallbackPaths.length === 0) {
|
||||
console.error("[test] no changed test targets; skipping Vitest.");
|
||||
return;
|
||||
}
|
||||
|
||||
console.error("[test] no precise changed test targets; skipping Vitest.");
|
||||
console.error(
|
||||
`[test] ${skippedBroadFallbackPaths.length} changed path${
|
||||
skippedBroadFallbackPaths.length === 1 ? "" : "s"
|
||||
} require broad Vitest fallback:`,
|
||||
);
|
||||
for (const changedPath of skippedBroadFallbackPaths) {
|
||||
console.error(`[test] ${changedPath}`);
|
||||
}
|
||||
console.error("[test] run `OPENCLAW_TEST_CHANGED_BROAD=1 pnpm test:changed` for broad coverage.");
|
||||
}
|
||||
|
||||
async function runVitestSpecsParallel(specs, concurrency) {
|
||||
let nextIndex = 0;
|
||||
let exitCode = 0;
|
||||
@@ -263,7 +284,7 @@ async function main() {
|
||||
);
|
||||
|
||||
if (runSpecs.length === 0) {
|
||||
console.error("[test] no changed test targets; skipping Vitest.");
|
||||
printNoChangedTestTargets(args, process.cwd(), baseEnv);
|
||||
printTestSummary("skipped", 0, performance.now() - suiteStartedAt);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -158,6 +158,21 @@ function withTinyGitRepo(files: Record<string, string>, test: (cwd: string) => v
|
||||
}
|
||||
}
|
||||
|
||||
function commitTinyGitRepo(cwd: string): void {
|
||||
const commit = spawnSync("git", ["commit", "-m", "initial"], {
|
||||
cwd,
|
||||
env: {
|
||||
...process.env,
|
||||
GIT_AUTHOR_EMAIL: "test@example.com",
|
||||
GIT_AUTHOR_NAME: "OpenClaw Test",
|
||||
GIT_COMMITTER_EMAIL: "test@example.com",
|
||||
GIT_COMMITTER_NAME: "OpenClaw Test",
|
||||
},
|
||||
stdio: "ignore",
|
||||
});
|
||||
expect(commit.status).toBe(0);
|
||||
}
|
||||
|
||||
function withTinyFileTree(files: Record<string, string>, test: (cwd: string) => void): void {
|
||||
const cwd = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-test-projects-"));
|
||||
try {
|
||||
@@ -1162,6 +1177,29 @@ describe("scripts/test-projects changed-target routing", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("explains changed paths that need explicit broad fallback before skipping", () => {
|
||||
withTinyGitRepo({ "package.json": '{"scripts":{}}\n' }, (cwd) => {
|
||||
commitTinyGitRepo(cwd);
|
||||
fs.writeFileSync(path.join(cwd, "package.json"), '{"scripts":{"test":"node"}}\n');
|
||||
|
||||
const result = spawnSync(
|
||||
process.execPath,
|
||||
[path.resolve(process.cwd(), "scripts/test-projects.mjs"), "--changed", "HEAD"],
|
||||
{
|
||||
cwd,
|
||||
encoding: "utf8",
|
||||
},
|
||||
);
|
||||
|
||||
expect(result.status).toBe(0);
|
||||
expect(result.stderr).toContain("[test] no precise changed test targets; skipping Vitest.");
|
||||
expect(result.stderr).toContain("[test] package.json");
|
||||
expect(result.stderr).toContain(
|
||||
"[test] run `OPENCLAW_TEST_CHANGED_BROAD=1 pnpm test:changed` for broad coverage.",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps the broad changed run available for unknown root surfaces", () => {
|
||||
expect(
|
||||
resolveChangedTargetArgs(
|
||||
|
||||
Reference in New Issue
Block a user