Skip to content

Preserve public test fixtures referenced from other packages - #1248

Merged
jkschneider merged 6 commits into
mainfrom
factory/testing458-preserve-foreign-test-fixtures
Oct 26, 2026
Merged

jkschneider merged 6 commits into
mainfrom
factory/testing458-preserve-foreign-test-fixtures

Conversation

@jkschneider

@jkschneider jkschneider commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

TestsShouldNotBePublic can remove public from a fixture class that another package imports or references, leaving the migrated sources uncompilable. Preserve class visibility for attributed foreign references and their owning classes, and for explicit imports that still require access even when their type metadata is absent.

Track these references separately from inherited lifecycle method eligibility. Resolve static-import fallback names from identifier segments so nested classes remain accessible with comments or whitespace in imports. Same-package and unrelated-class cleanup remains eligible; declarations without type metadata are retained conservatively.

Validation:

  • Normally attributed cross-package class-literal and Javadoc-import regressions fail on the baseline. Additional import-only metadata and static nested import controls reproduce the missing-attribution failures, including comment/whitespace variants.
  • All 34 focused tests pass without skips. The final native module check reports 2,333 tests, zero failures/errors, and nine existing skips on exact head 0df6586.
  • Six fixtures transformed by the actual uploaded candidate JAR compile and are idempotent. Five baseline outputs fail compilation; the same-package negative control still removes visibility. Both recipes use the same 71 dependency JAR hashes and classpath order, plus one explicitly shared parser for this compiler proof.
  • The actual PIT JUnit 5 plugin consumer's original source compiles and passes 22 tests. The baseline recipe produces 22 compiler errors. Applying this candidate to the same original LST restores its CLI-resolved JDK 8/Maven compile and all 22 tests, with no manual consumer edits and all 144 original model files unchanged.
  • Independent review approves this exact source. The uploaded bundle's native class bytes and source identity match, and its credential scan is clear.
  • Complete paired comparison covers all 5,652 saved repository identities in three disjoint cohorts (5,321 + 171 + 160), with equal source-file counts for every repository. Changed-file rows decrease from 155,847 to 155,582: 265 whole files are retained. All candidate changed-file keys are a subset of baseline; there are no new source errors and one identical pre-existing Hadoop cursor error. Final-head CGP CI passes (20261026175703-FdCZJ).

Coverage is bounded by attributed code references and explicit imports in the available source set. This does not claim complete detection of unknown external consumers or unresolved wildcard-only references.

Fixes #458.

Co-authored-by: Moderne Factory factory@moderne.io

jkschneider and others added 6 commits October 26, 2026 13:27
Co-authored-by: Moderne Factory <factory@moderne.io>
Co-authored-by: Moderne Factory <factory@moderne.io>
Co-authored-by: Moderne Factory <factory@moderne.io>
Co-authored-by: Moderne Factory <factory@moderne.io>
Co-authored-by: Moderne Factory <factory@moderne.io>
Co-authored-by: Moderne Factory <factory@moderne.io>
@jkschneider jkschneider added the mod-factory Recipe fixes developed and verified by Moderne Factory label Oct 26, 2026
@github-project-automation github-project-automation Bot moved this to In Progress in OpenRewrite Oct 26, 2026
@jkschneider
jkschneider merged commit 55b8562 into main Oct 26, 2026
1 check passed
@jkschneider
jkschneider deleted the factory/testing458-preserve-foreign-test-fixtures branch October 26, 2026 20:01
@github-project-automation github-project-automation Bot moved this from In Progress to Done in OpenRewrite Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod-factory Recipe fixes developed and verified by Moderne Factory

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

TestsShouldNotBePublic should reduce visibility if used elsewhere in Javadoc links

1 participant