Skip to content

Run tests that need a newer JDK in classes and folders of their own - #231

Merged
abashev merged 6 commits into
21.X.Xfrom
abashev/JDK-split-tests
Nov 15, 2026
Merged

abashev merged 6 commits into
21.X.Xfrom
abashev/JDK-split-tests

Conversation

@abashev

@abashev abashev commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

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/ becomes test-cases-java21/, moved as it is, in a commit of its own.
  • One class per JDK runs the cases, JDK 21 too: FormatterCasesJava21Test runs test-cases-java21, FormatterCasesJava25Test test-cases-java25 and test-cases-java21, FormatterCasesJava28Test all three. Each is enabled from its JDK on, with no upper bound. FormatterCasesTest keeps casesIn(String... folders), which they share.
  • Module imports: ModuleImportTest, and the module-import test of RemoveUnusedImportsTest moved to RemoveUnusedImportsJava25Test, carry @EnabledForJreRange(min = JRE.JAVA_25). The ModuleImport pair of FormatterIntegrationTest becomes test-cases-java25/moduleImports.case; VERSIONED_TESTS and assumeJavaVersionForTest go.
  • Value classes, a preview of JDK 28: the formatting test of FormatterTest becomes test-cases-java28/valueClasses.case, and the test of ModifierOrdererTest moves to ModifierOrdererJava28Test, both with @EnabledForJreRange(min = JRE.JAVA_28). JDK 28's early-access builds, which CI runs, have the value modifier.
  • moduleImports.case gets its imports shuffled on input: the ordinary import first, the module imports reversed.

What changes

  • No assumeTrue on the runtime is left inside a test. A class whose JDK range excludes the runtime reports as skipped as a whole.
  • Module-import tests start at JDK 25 instead of 23; CI runs no 23 or 24.
  • The ModuleImport pair ran as 4 tests of FormatterIntegrationTest, formatting and three line-ending variants; as a case it runs once, formatting and formatting again, through formatSourceAndFixImports, and gives the same output.

Tests

  • JDK 21: :open-java-format:check passes; 1,419 tests, 11 skipped, all of them the JDK 25 and 28 classes (before: 1,422, 14 skipped by assumptions). FormatterCasesJava21Test runs 915 cases.
  • JDK 25 (-PjavaRuntime=25): 2,334 tests, 2 skipped, the two JDK 28 classes; FormatterCasesJava21Test runs 915 cases and FormatterCasesJava25Test 916.
  • JDK 28 (Temurin 28+23-ea, -PjavaRuntime=28): 3,250 tests, none skipped; the three classes run 915, 916 and 917 cases.
  • The first commit passes :open-java-format:test on its own.

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.
@abashev
abashev merged commit 4a29a26 into 21.X.X Nov 15, 2026
17 checks passed
@abashev
abashev deleted the abashev/JDK-split-tests branch November 15, 2026 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant