fix(test): avoid runtime rebuilds after test utility edits (#163571)

Exclude dotted .test-utils.ts and .test-utils.tsx paths through the existing build-input owner. Preserve runtime support inputs and extend the existing build-stamp regression.

The controlled prepared test-utility-edit workflow at db793644 improved from 67.205s to 27.870s mean wall time. Current-source correctness and changed-file gates remain pending in the draft PR.
This commit is contained in:
Peter Steinberger 2026-10-02 10:10:28 -07:00 • committed by GitHub
parent b5a41c2001
commit dd5ff2c382
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 35 additions and 0 deletions

View file

@ -51,6 +51,8 @@ export const normalizeRunNodePath = (filePath: unknown): string =>
export const isIgnoredRunNodeSourcePath = (relativePath: string): boolean =>
relativePath.endsWith(".test.ts") ||
relativePath.endsWith(".test.tsx") ||
relativePath.endsWith(".test-utils.ts") ||
relativePath.endsWith(".test-utils.tsx") ||
relativePath.endsWith("test-helpers.ts");
const isBuildRelevantSourcePath = (relativePath: string): boolean =>

View file

@ -57,6 +57,23 @@ it("reuses built dirty inputs but rejects changed production, dependencies and m
await write("package.json", '{"name":"openclaw"}');
await write("src/index.ts", "export const value = 1;\n");
await write("src/index.test.ts", "original fixture\n");
const testUtilities = ["src/index.test-utils.ts", "src/index.test-utils.tsx"];
for (const file of testUtilities) {
await write(file, "original fixture\n");
}
const runtimeSupport = [
"src/test-utils.ts",
"src/runtime.test-support.ts",
"src/runtime.test-harness.ts",
"src/test-api.ts",
];
for (const file of runtimeSupport) {
await write(file, "export const value = 1;\n");
}
await write(
"src/runtime-entry.ts",
runtimeSupport.map((file) => `import "./${path.basename(file, ".ts")}.js";`).join("\n"),
);
await write("src/stable.ts", "export const stable = 1;\n");
await write("pnpm-lock.yaml", "original lockfile\n");
for (const args of [
@ -128,6 +145,22 @@ it("reuses built dirty inputs but rejects changed production, dependencies and m
await fs.unlink(path.join(cwd, "deployment.json"));
await write("src/index.test.ts", "corrected fixture\n");
expect(resolveBuildRequirement(deps, { allowEquivalentInputs: true }).shouldBuild).toBe(false);
for (const file of testUtilities) {
await write(file, "corrected fixture\n");
expect(resolveBuildRequirement(deps, { allowEquivalentInputs: true }).shouldBuild).toBe(
false,
);
}
for (const file of runtimeSupport) {
await write(file, "export const value = 2;\n");
expect(resolveBuildRequirement(deps, { allowEquivalentInputs: true }).reason).toBe(
"build_inputs_changed",
);
await write(file, "export const value = 1;\n");
expect(resolveBuildRequirement(deps, { allowEquivalentInputs: true }).shouldBuild).toBe(
false,
);
}
await fs.rename(path.join(cwd, "src/index.ts"), path.join(cwd, "src/renamed.ts"));
expect(resolveBuildRequirement(deps, { allowEquivalentInputs: true }).shouldBuild).toBe(true);
await fs.rename(path.join(cwd, "src/renamed.ts"), path.join(cwd, "src/index.ts"));