mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-03 17:53:39 +00:00
Exercise dependency inputs against a small filesystem fixture through the real planner instead of rebuilding the growing repository inventory for each case. Keep every existing assertion and require package/lockfile changes to retain their direct reader. Real-checkout compositions remain in the integration owner. Validation: 95 original-order cases, the real-checkout mixed-hub integration, selected changed checks, and independent P2 review pass. On macOS Node 24.21, the planner file drops from 76.15s to 3.29s and its first case from 15.93s to 0.348s. The Linux Node 24.19 120s CI timeout remains unreproduced locally. Whole-group wall time was 150s versus 125s with the unchanged process-test sibling and overlapping checks; no whole-group speed improvement is claimed.
88 lines
3.5 KiB
TypeScript
88 lines
3.5 KiB
TypeScript
import { mkdirSync, writeFileSync } from "node:fs";
|
|
import path from "node:path";
|
|
import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
|
|
import {
|
|
createChangedNodeTestShards as createChangedNodeTestShardsWithSmoke,
|
|
resolveChangedNodeTestTargets,
|
|
} from "../../scripts/lib/ci-changed-node-test-plan.mts";
|
|
import * as testProjects from "../../scripts/test-projects.test-support.mts";
|
|
import { useAutoCleanupTempDirTracker } from "../helpers/temp-dir.js";
|
|
import {
|
|
smokeTestFiles,
|
|
createChangedNodeTestShards,
|
|
selectedFiles,
|
|
} from "./ci-changed-node-test-plan.test-support.js";
|
|
|
|
const globalInputs = [
|
|
"tsconfig.json",
|
|
"pnpm-workspace.yaml",
|
|
".npmrc",
|
|
"node-version.mjs",
|
|
"test/setup.ts",
|
|
"vitest.config.ts",
|
|
"patches/runtime.patch",
|
|
];
|
|
const tempDirs = useAutoCleanupTempDirTracker(afterAll);
|
|
let cwd: string;
|
|
|
|
beforeAll(() => {
|
|
cwd = tempDirs.make("changed-node-dependency-inputs-");
|
|
const files = {
|
|
...Object.fromEntries(globalInputs.map((file) => [file, file.endsWith(".json") ? "{}" : ""])),
|
|
"package.json": "{}",
|
|
"pnpm-lock.yaml": "",
|
|
"src/agents/live-provider-owner.ts": "export const value = 1;\n",
|
|
"src/agents/live-model-filter.test.ts": 'import "./live-provider-owner.js";\n',
|
|
"src/cron/service.stream-trigger.test.ts": "export {};\n",
|
|
"src/example/dependency-reader.test.ts":
|
|
'new URL("../../package.json", import.meta.url);\nnew URL("../../pnpm-lock.yaml", import.meta.url);\n',
|
|
};
|
|
for (const [file, source] of Object.entries(files)) {
|
|
mkdirSync(path.dirname(path.join(cwd, file)), { recursive: true });
|
|
writeFileSync(path.join(cwd, file), source);
|
|
}
|
|
});
|
|
|
|
describe("CI changed Node test plan", () => {
|
|
it.each(globalInputs)("keeps %s owner coverage beside a precise source change", (globalInput) => {
|
|
const onFallback = vi.fn();
|
|
const shards = createChangedNodeTestShards(["src/agents/live-provider-owner.ts", globalInput], {
|
|
cwd,
|
|
onFallback,
|
|
});
|
|
expect(shards).not.toBeNull();
|
|
expect(selectedFiles(shards)).toContain("src/agents/live-model-filter.test.ts");
|
|
expect(selectedFiles(shards)).not.toContain("src/cron/service.stream-trigger.test.ts");
|
|
expect(onFallback).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it.each(["package.json", "pnpm-lock.yaml"])(
|
|
"keeps dependency hub %s bounded even when exact history is unavailable",
|
|
(changedPath) => {
|
|
const onFallback = vi.fn();
|
|
const shards = createChangedNodeTestShards([changedPath], { cwd, onFallback });
|
|
expect(shards).not.toBeNull();
|
|
expect(selectedFiles(shards)).toContain("src/example/dependency-reader.test.ts");
|
|
expect(selectedFiles(shards)).not.toContain("src/cron/service.stream-trigger.test.ts");
|
|
expect(onFallback).not.toHaveBeenCalled();
|
|
},
|
|
);
|
|
|
|
it("rejects missing or unresolved changed-path input before producing a partial plan", () => {
|
|
const onFallback = vi.fn();
|
|
expect(createChangedNodeTestShards([], { onFallback })).toBeNull();
|
|
expect(onFallback).toHaveBeenCalledWith("missing changed paths");
|
|
const plan = vi.spyOn(testProjects, "resolveChangedTestTargetPlan");
|
|
try {
|
|
for (const mode of ["broad", "none"] as const) {
|
|
plan.mockReturnValue({ mode, targets: [] });
|
|
expect(() => createChangedNodeTestShardsWithSmoke(["src/infra/retry.ts"])).toThrow(
|
|
`Unresolved changed-owner test plan: ${mode}`,
|
|
);
|
|
}
|
|
expect(resolveChangedNodeTestTargets(["docs/ci.md"])).toEqual([...smokeTestFiles].toSorted());
|
|
} finally {
|
|
plan.mockRestore();
|
|
}
|
|
});
|
|
});
|