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:
@@ -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