Skip to content

Commit

Permalink
Run switch test only if java >= 14
Browse files Browse the repository at this point in the history
  • Loading branch information
caesar-ralf committed Oct 6, 2023
1 parent 1af2f00 commit 7fe4b4d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/test/java/com/spotify/fmt/FMTTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public void forkAlways() throws Exception {

@Test
public void forkNeverBeforeJDK16() throws Exception {
assumeFalse(javaRuntimeStronglyEncapsulatesByDefault()); // Skip if forking is needed.
assumeFalse(isJavaVersionEqualOrHigherThan("16")); // Skip if forking is needed.
FMT fmt = loadMojo("fork_never_beforejdk16", FORMAT);
assertThat(fmt.shouldFork()).isFalse();
fmt.execute();
Expand All @@ -189,7 +189,7 @@ public void forkNeverBeforeJDK16() throws Exception {
expected =
IllegalAccessError.class) // Could stop throwing this if google-java-format is fixed.
public void forkNeverAfterJDK16() throws Exception {
assumeTrue(javaRuntimeStronglyEncapsulatesByDefault()); // Skip if forking is not needed.
assumeTrue(isJavaVersionEqualOrHigherThan("16"));
FMT fmt = loadMojo("fork_never_afterjdk16", FORMAT);
assertThat(fmt.shouldFork()).isFalse();
fmt.execute();
Expand All @@ -207,6 +207,7 @@ public void unsupportedForkMode() throws Exception {

@Test
public void switchWithArrows() throws Exception {
assumeTrue(isJavaVersionEqualOrHigherThan("14"));
FMT fmt = loadMojo("switchwitharrows", FORMAT);

fmt.execute();
Expand Down Expand Up @@ -331,7 +332,7 @@ private Log setupLogSpy(Mojo mojo) {
return spy;
}

private static boolean javaRuntimeStronglyEncapsulatesByDefault() {
return Runtime.version().compareTo(Runtime.Version.parse("16")) >= 0;
private static boolean isJavaVersionEqualOrHigherThan(final String javaVersion) {
return Runtime.version().compareTo(Runtime.Version.parse(javaVersion)) >= 0;
}
}

0 comments on commit 7fe4b4d

Please sign in to comment.