Skip to content

fix(build): detect orphaned compiled tests before building - #5647

Open
seekskyworld wants to merge 2 commits into
apache:mainfrom
seekskyworld:fix/5641-orphaned-test-output
Open

seekskyworld wants to merge 2 commits into
apache:mainfrom
seekskyworld:fix/5641-orphaned-test-output

Conversation

@seekskyworld

@seekskyworld seekskyworld commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

After a test source is removed or renamed, incremental TypeScript builds leave its compiled copy in dist, and test:dist still runs it. Root npm run build now detects these orphaned tests before compiling, lists their paths, and directs contributors to npm run rebuild, which clears both output and incremental state.

The check preserves normal incremental builds and does not delete individual compiler outputs. It covers the repository's src → dist layouts, including Desktop's nested main tests and UI TSX tests. Contributor guidance and CI regression coverage are included.

Fixes #5641

Verification

  • Real TypeScript reproduction: compile a test, delete its source, compile again; both compilations succeed and the old test remains. The new guard exits 1 and reports that file.
  • 140 script tests pass, including four new cases covering deleted/renamed tests, supported source extensions, clean checkouts, and the actual npm build/rebuild lifecycle. Removing the prebuild hook makes the lifecycle regression fail.
  • Full repository build, typecheck, lint, format check, Desktop/UI knip, ASF headers, and diff checks pass on Node 24.18.1. The guard also passes against the completed repository build.
  • npm run check:release passes all 203 release-contract tests; 19 focused guard/file-policy tests pass. The first hosted run identified fixture paths that looked like real workspace references; the fixture namespace was corrected in the follow-up commit and the revised tests pass in CI.
  • Application workspace test suites were not rerun; this change affects build tooling only.

Hosted check

On head 0e34d7ee5, Windows/Linux packaging, audits, and both owner checks pass. The main test run 35902091783 fails in the unchanged storage test bundle export excludes a mutation queued behind the same child-held writer lock: the export contained after-export as well as seed. This is a separate failure from the corrected fixture-path issue; CI is not green. The new build-guard tests and release contracts passed in this run.

AI use

  • No generative tool made a substantive contribution
  • Generative tooling made a substantive contribution

Tool(s) and scope: OpenAI Codex inspected the issue, implemented and tested the build guard, and drafted this description under human direction.

Checklist

  • Tests cover the change and fail without it
  • Lint, format, typecheck and the affected suites pass locally

Does this PR entail a change in behavior?

  • Yes — described under Summary above
  • No

Generated-by: OpenAI Codex
Signed-off-by: seekskyworld <djh1813553759@gmail.com>
@github-actions github-actions Bot added the effort/M Under 500 readable lines label Sep 23, 2026
Generated-by: OpenAI Codex
Signed-off-by: seekskyworld <djh1813553759@gmail.com>

@hqhq1025 hqhq1025 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the current six-file root prebuild scanner for orphan compiled test artifacts and its tests. I found no substantiated P0–P3 issue attributable to this change; the four focused scanner tests and diff check pass. This is not ready to merge: the current-head required test check is failing in an unchanged storage artifact-writer-lock concurrency test (PR attribution remains unproven), and this branch conflicts with main. Please resolve the conflict and investigate/rerun the required check before merge. I did not run the full test suite or validate every build artifact layout.

Automated review notice: This comment was posted by an automated review agent operated by hqhq1025. It is not an independent human review and does not replace one.

@me2seeks me2seeks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review notice: This comment was posted by an automated review agent operated by me2seeks make. It is not an independent human review and does not replace one.

Summary

Adds a root prebuild guard that fails the build when dist/**/*.test.{js,jsx,mjs,cjs} has no matching source under src/, with docs and a CI lane. The issue is real — incremental tsc never deletes outputs for removed sources, and test:dist then runs ghost tests. The solution is minimal (detect + direct to npm run rebuild rather than deleting), workspaces are explicit paths (package.json:16-30), Desktop's nested dist/main/__tests__ layout and .d.ts/.map siblings are correctly handled, and the npm-lifecycle test would fail if the hook were dropped.

Findings

  1. [P2] The test lane is red on the current head (run 35902091783): storage test bundle export excludes a mutation queued behind the same child-held writer lock. The body claims it is unrelated to this build-tooling change — plausible, but it must be re-run green or demonstrated to fail on unmodified main before merge.
  2. No code-level findings. The check correctly no-ops on unbuilt checkouts, skips symlinked entries, keeps module-specific extension mapping (mjs→mts/mjs, cjs→cts/cjs), and its mutation coverage is real (removing the prebuild hook fails the lifecycle regression).

Verdict

needs-discussion — code is merge-ready, but the failing test lane on head needs a green re-run or proof of pre-existing failure.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/M Under 500 readable lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(scripts): build leaves compiled tests for deleted sources in dist, and they still run

3 participants