Skip to content

Commit

Permalink
[Java14] Adjust Gradle and PIT compatible version for JDK 14
Browse files Browse the repository at this point in the history
  • Loading branch information
szpak committed Mar 14, 2020
1 parent a8ec19b commit 01dcf22
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ abstract class AbstractPitestFunctionalSpec extends IntegrationSpec {

//TODO: Switch to Gradle mechanism once upgraded to 6.x
protected boolean isJava13Compatible() {
return System.getProperty("java.version").startsWith("13") || System.getProperty("java.version").startsWith("14")
return System.getProperty("java.version").startsWith("13") || isJava14Compatible()
}

protected boolean isJava14Compatible() {
return System.getProperty("java.version").startsWith("14") || System.getProperty("java.version").startsWith("15")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class PitestPluginGradleVersionFunctionalSpec extends AbstractPitestFunctionalSp
private static final GradleVersion MINIMAL_SUPPORTED_JAVA12_COMPATIBLE_GRADLE_VERSION = PitestPlugin.MINIMAL_SUPPORTED_GRADLE_VERSION
//6.0+ - https://github.com/gradle/gradle/issues/8681#issuecomment-532507276
private static final GradleVersion MINIMAL_SUPPORTED_JAVA13_COMPATIBLE_GRADLE_VERSION = GradleVersion.version("6.0.1")
//6.3+ - https://github.com/gradle/gradle/issues/10248
private static final GradleVersion MINIMAL_SUPPORTED_JAVA14_COMPATIBLE_GRADLE_VERSION = GradleVersion.version("6.3-rc-1")

void setup() {
daemonMaxIdleTimeInSecondsInMemorySafeMode = 1 //trying to mitigate "Gradle killed" issues with Travis
Expand Down Expand Up @@ -90,7 +92,7 @@ class PitestPluginGradleVersionFunctionalSpec extends AbstractPitestFunctionalSp
//TODO: Extract regression tests control mechanism to a separate class (or even better trait) when needed in some other place
private static final String REGRESSION_TESTS_ENV_NAME = "PITEST_REGRESSION_TESTS"
private static final List<String> GRADLE5_VERSIONS = ["5.6.1", "5.6"]
private static final List<String> GRADLE6_VERSIONS = ["6.2.1", "6.1.1", MINIMAL_SUPPORTED_JAVA13_COMPATIBLE_GRADLE_VERSION.version]
private static final List<String> GRADLE6_VERSIONS = ["6.3-rc-1", "6.2.1", "6.1.1", MINIMAL_SUPPORTED_JAVA13_COMPATIBLE_GRADLE_VERSION.version]
private static final List<String> GRADLE_LATEST_VERSIONS = [GRADLE5_VERSIONS.first(), GRADLE6_VERSIONS.first()]

private List<String> resolveRequestedGradleVersions() {
Expand All @@ -117,8 +119,9 @@ class PitestPluginGradleVersionFunctionalSpec extends AbstractPitestFunctionalSp
//All supported versions should be Java 8 compatible
return requestedGradleVersions
}
GradleVersion minimalCompatibleGradleVersion = !isJava13Compatible() ? MINIMAL_SUPPORTED_JAVA12_COMPATIBLE_GRADLE_VERSION :
MINIMAL_SUPPORTED_JAVA13_COMPATIBLE_GRADLE_VERSION
GradleVersion minimalCompatibleGradleVersion = !isJava14Compatible() ? MINIMAL_SUPPORTED_JAVA13_COMPATIBLE_GRADLE_VERSION :
!isJava13Compatible() ? MINIMAL_SUPPORTED_JAVA12_COMPATIBLE_GRADLE_VERSION :
MINIMAL_SUPPORTED_JAVA14_COMPATIBLE_GRADLE_VERSION
return leaveJavaXCompatibleGradleVersionsOnly(requestedGradleVersions, minimalCompatibleGradleVersion)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class PitestPluginPitVersionFunctionalSpec extends AbstractPitestFunctionalSpec
private static final String MINIMAL_JAVA10_COMPATIBLE_PIT_VERSION = "1.4.0"
private static final String MINIMAL_JAVA11_COMPATIBLE_PIT_VERSION = "1.4.2" //in fact 1.4.1, but 1.4.2 is also Java 12 compatible
private static final String MINIMAL_JAVA13_COMPATIBLE_PIT_VERSION = "1.4.6" //not officially, but at least simple case works
private static final String MINIMAL_JAVA14_COMPATIBLE_PIT_VERSION = "1.4.11" //not officially, but with ASM 7.3.1

def "setup and run pitest task with PIT #pitVersion"() {
given:
Expand All @@ -35,10 +36,13 @@ class PitestPluginPitVersionFunctionalSpec extends AbstractPitestFunctionalSpec
result.standardOutput.contains('Generated 2 mutations Killed 1 (50%)')
result.standardOutput.contains('Ran 2 tests (1 tests per mutation)')
where:
pitVersion << getPitVersionsCompoatibleWithCurrentJavaVersion().unique() //be aware that unique() is available since Groovy 2.4.0
pitVersion << getPitVersionsCompatibleWithCurrentJavaVersion().unique() //be aware that unique() is available since Groovy 2.4.0
}

private List<String> getPitVersionsCompoatibleWithCurrentJavaVersion() {
private List<String> getPitVersionsCompatibleWithCurrentJavaVersion() {
if (isJava14Compatible()) {
return [PitestPlugin.DEFAULT_PITEST_VERSION, MINIMAL_JAVA14_COMPATIBLE_PIT_VERSION]
}
if (isJava13Compatible()) {
return [PitestPlugin.DEFAULT_PITEST_VERSION, MINIMAL_JAVA13_COMPATIBLE_PIT_VERSION]
}
Expand Down

0 comments on commit 01dcf22

Please sign in to comment.