mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
fix(test): avoid empty script changed runs
This commit is contained in:
@@ -1647,8 +1647,11 @@ function resolveToolingChangedTestTargets(changedPaths, cwd = process.cwd()) {
|
||||
return [...new Set(targets)];
|
||||
}
|
||||
|
||||
const TOOLING_SCRIPT_PATH_PATTERN =
|
||||
/^scripts\/(.+)\.(?:mjs|cjs|js|mts|cts|ts|sh|py|ps1)$/u;
|
||||
|
||||
function resolveConventionalToolingTestTargets(changedPath, cwd = process.cwd()) {
|
||||
const match = /^scripts\/(.+)\.(?:mjs|ts|js|sh|py)$/u.exec(changedPath);
|
||||
const match = TOOLING_SCRIPT_PATH_PATTERN.exec(changedPath);
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
@@ -1667,6 +1670,10 @@ function resolveConventionalToolingTestTargets(changedPath, cwd = process.cwd())
|
||||
return targets.length > 0 ? targets : null;
|
||||
}
|
||||
|
||||
function isToolingScriptPath(changedPath) {
|
||||
return TOOLING_SCRIPT_PATH_PATTERN.test(changedPath);
|
||||
}
|
||||
|
||||
function resolveParallelsToolingTestTargets(changedPath) {
|
||||
if (!/^scripts\/e2e\/parallels\/[^/]+\.ts$/u.test(changedPath)) {
|
||||
return null;
|
||||
@@ -1697,7 +1704,11 @@ function resolveToolingTestTargets(changedPath, cwd = process.cwd()) {
|
||||
if (explicitTargets && conventionalTargets) {
|
||||
return uniqueOrdered([...explicitTargets, ...conventionalTargets]);
|
||||
}
|
||||
return explicitTargets ?? conventionalTargets;
|
||||
return (
|
||||
explicitTargets ??
|
||||
conventionalTargets ??
|
||||
(isToolingScriptPath(changedPath) ? [TOOLING_VITEST_CONFIG] : null)
|
||||
);
|
||||
}
|
||||
|
||||
function shouldUseBroadChangedTargets(env = process.env) {
|
||||
|
||||
@@ -267,6 +267,29 @@ describe("scripts/test-projects changed-target routing", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("routes unmatched script changes to the tooling suite instead of skipping tests", () => {
|
||||
const targets = [
|
||||
"scripts/check-no-raw-http2-imports.mjs",
|
||||
"scripts/e2e/lib/clawhub-fixture-server.cjs",
|
||||
"scripts/install.ps1",
|
||||
];
|
||||
|
||||
expect(resolveChangedTestTargetPlan(targets)).toEqual({
|
||||
mode: "targets",
|
||||
targets: ["test/vitest/vitest.tooling.config.ts"],
|
||||
});
|
||||
expect(buildVitestRunPlans(["--changed", "origin/main"], process.cwd(), () => targets)).toEqual(
|
||||
[
|
||||
{
|
||||
config: "test/vitest/vitest.tooling.config.ts",
|
||||
forwardedArgs: [],
|
||||
includePatterns: null,
|
||||
watchMode: false,
|
||||
},
|
||||
],
|
||||
);
|
||||
});
|
||||
|
||||
it("routes Z.AI fallback repro script changes through its regression test", () => {
|
||||
expect(resolveChangedTestTargetPlan(["scripts/zai-fallback-repro.ts"])).toEqual({
|
||||
mode: "targets",
|
||||
|
||||
Reference in New Issue
Block a user