Repository navigation
Only collapse the JRE range of the visited method in MinimumJreConditions - #1242
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a test's JRE range ended on the minimum version,
MinimumJreConditionsqueued a file-wideChangeTypeand attribute edits withdoAfterVisit. Every range annotation of that type in the file was rewritten, so withjavaVersion17@EnabledForJreRange(min = JAVA_21)on another method became@EnabledOnJre(JAVA_17)and enabled that test on a JRE it should skip. The recipe now swaps only the visited method's range annotation for an@EnabledOnJre/@DisabledOnJrebuilt with a typedJavaTemplate. Before, a staticJAVA_17was written untyped and theimport static ...JRE.*was dropped. Now it is typed and the import stays.Two other problems in the same recipe:
@EnabledOnJre({JRE.JAVA_11, JRE.JAVA_17, JRE.JAVA_21})wrote the JRE constants into the intversionsattribute, which failed the recipe run. The recipe now removes the outdated elements from the array where they are, whatever the attribute, and keeps the original formatting. Because of that, two existing expectations now keep{ 17, 21 }as written instead of reformatting it to{17, 21}. A bare array left with one element is unwrapped, as assignments already were.@EnabledForJreRange(minVersion = MIN), madeInteger.parseIntthrow. Those methods are now left alone.The missing precondition in the issue was already added in #1227.
Verified with
./gradlew test --offline --tests 'org.openrewrite.java.testing.junit6.*': 97 tests, 1 failure. The failure isJUnit5to6MigrationTest.leavesGradleModuleUsingTestNgAlone, a Gradle Tooling API test that couldn't fetch its model locally. Onmain, all 5 newMinimumJreConditionsTestcases fail.Fixes item C10 of #1211.