From dd5ff2c382041bdbe070531c654f4e22fcbbdcac Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 2 Oct 2026 10:10:28 -0700 Subject: [PATCH] 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. --- scripts/run-node-watch-paths.mts | 2 ++ src/infra/build-stamp.test.ts | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/scripts/run-node-watch-paths.mts b/scripts/run-node-watch-paths.mts index 55f75caefde9..66fc100a8a7a 100644 --- a/scripts/run-node-watch-paths.mts +++ b/scripts/run-node-watch-paths.mts @@ -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 => diff --git a/src/infra/build-stamp.test.ts b/src/infra/build-stamp.test.ts index 3707f5e0497e..a374aa4658ab 100644 --- a/src/infra/build-stamp.test.ts +++ b/src/infra/build-stamp.test.ts @@ -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"));