Repository navigation
Run tests that need a newer JDK in classes and folders of their own - #231
Merged
Merged
Conversation
The cases are to live in a folder for each JDK they need, side by side, and these are the ones for any JDK from 21 (ADR-002). Moved as they are; FormatterCasesTest reads the new folder, and the two comments that name it follow.
Tests that need a newer JDK skipped themselves from inside, in three ways, and counted as skipped on JDK 21 among the tests that run (ADR-002). Each now says what it needs on its class: - ModuleImportTest, and the module-import test of RemoveUnusedImportsTest moved to RemoveUnusedImportsJava25Test, carry @EnabledForJreRange(min = JAVA_25), where module imports are final; they started at JDK 23 before, which CI does not run. - The ModuleImport pair of FormatterIntegrationTest is a case in test-cases-java25/, run by FormatterCasesJava25Test, so VERSIONED_TESTS and assumeJavaVersionForTest go. - The value-class tests of FormatterTest and ModifierOrdererTest move to ValueClassTest, enabled where javac has the value modifier: they need a JDK with Valhalla, not a version.
The value classes of JEP 401 are a preview of JDK 28, and its early-access builds have the `value` modifier, so their tests go by the version, as the module imports do, rather than by a condition on Modifier.VALUE: the formatting one becomes a case in test-cases-java28, run by FormatterCasesJava28Test, and the ModifierOrderer one moves to ModifierOrdererJava28Test, both from JDK 28. The module-import case had its imports already in order; its input now has the ordinary import first and the module imports reversed.
FormatterCasesJava21Test, Java25Test and Java28Test each run the case folders their JDK parses, named in the class: one, two or three. Their JDK ranges do not overlap, so on any JDK every case runs once. FormatterCasesTest keeps what they share, casesIn, which takes the folders.
FormatterCasesJava21Test runs from JDK 21, Java25Test from 25 and Java28Test from 28. On a newer JDK the cases of the older folders run once more in the newer classes.
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.
Tests that need a newer JDK say so on their class, and their case files live in a folder of that JDK, as ADR-002 (#230) records. First of the changes of the formatting contract; the next ones build on it.
test-cases/becomestest-cases-java21/, moved as it is, in a commit of its own.FormatterCasesJava21Testrunstest-cases-java21,FormatterCasesJava25Testtest-cases-java25andtest-cases-java21,FormatterCasesJava28Testall three. Each is enabled from its JDK on, with no upper bound.FormatterCasesTestkeepscasesIn(String... folders), which they share.ModuleImportTest, and the module-import test ofRemoveUnusedImportsTestmoved toRemoveUnusedImportsJava25Test, carry@EnabledForJreRange(min = JRE.JAVA_25). TheModuleImportpair ofFormatterIntegrationTestbecomestest-cases-java25/moduleImports.case;VERSIONED_TESTSandassumeJavaVersionForTestgo.FormatterTestbecomestest-cases-java28/valueClasses.case, and the test ofModifierOrdererTestmoves toModifierOrdererJava28Test, both with@EnabledForJreRange(min = JRE.JAVA_28). JDK 28's early-access builds, which CI runs, have thevaluemodifier.moduleImports.casegets its imports shuffled on input: the ordinary import first, the module imports reversed.What changes
assumeTrueon the runtime is left inside a test. A class whose JDK range excludes the runtime reports as skipped as a whole.ModuleImportpair ran as 4 tests ofFormatterIntegrationTest, formatting and three line-ending variants; as a case it runs once, formatting and formatting again, throughformatSourceAndFixImports, and gives the same output.Tests
:open-java-format:checkpasses; 1,419 tests, 11 skipped, all of them the JDK 25 and 28 classes (before: 1,422, 14 skipped by assumptions).FormatterCasesJava21Testruns 915 cases.-PjavaRuntime=25): 2,334 tests, 2 skipped, the two JDK 28 classes;FormatterCasesJava21Testruns 915 cases andFormatterCasesJava25Test916.-PjavaRuntime=28): 3,250 tests, none skipped; the three classes run 915, 916 and 917 cases.:open-java-format:teston its own.