[Test] Support various jdk targets in test infrastructure
This commit is contained in:
+38
-25
@@ -105,38 +105,51 @@ public class KtTestUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File getJdk9Home() {
|
||||
String jdk9 = System.getenv("JDK_9");
|
||||
if (jdk9 == null) {
|
||||
jdk9 = System.getenv("JDK_19");
|
||||
if (jdk9 == null) {
|
||||
throw new AssertionError("Environment variable JDK_9 is not set!");
|
||||
}
|
||||
}
|
||||
return new File(jdk9);
|
||||
private static File getJdkHome(@NotNull String prop) {
|
||||
return getJdkHome(prop, null, prop);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static File getJdk11Home() {
|
||||
String jdk11 = System.getenv("JDK_11");
|
||||
if (jdk11 == null) {
|
||||
return null;
|
||||
@NotNull
|
||||
private static File getJdkHome(@NotNull String prop, @Nullable String otherProp) {
|
||||
return getJdkHome(prop, otherProp, prop);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static File getJdkHome(@NotNull String prop, @Nullable String otherProp, @NotNull String propToReport) {
|
||||
String jdk = System.getenv(prop);
|
||||
if (jdk == null) {
|
||||
if (otherProp != null) {
|
||||
return getJdkHome(otherProp, null, prop);
|
||||
} else {
|
||||
throw new AssertionError("Environment variable " + propToReport + " is not set!");
|
||||
}
|
||||
}
|
||||
return new File(jdk11);
|
||||
return new File(jdk);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File getJdk6Home() {
|
||||
return getJdkHome("JDK_6", "JDK_16");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File getJdk8Home() {
|
||||
return getJdkHome("JDK_8", "JDK_18");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File getJdk9Home() {
|
||||
return getJdkHome("JDK_9", "JDK_19");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File getJdk11Home() {
|
||||
return getJdkHome("JDK_11");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File getJdk15Home() {
|
||||
String jdk15 = System.getenv("JDK_15");
|
||||
|
||||
if (jdk15 == null) {
|
||||
jdk15 = System.getenv("JDK_15_0");
|
||||
}
|
||||
|
||||
if (jdk15 == null) {
|
||||
throw new AssertionError("Environment variable JDK_15 is not set!");
|
||||
}
|
||||
return new File(jdk15);
|
||||
return getJdkHome("JDK_15", "JDK_15_0");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
+2
@@ -85,6 +85,8 @@ class JavaCompilerFacade(private val testServices: TestServices) {
|
||||
return
|
||||
}
|
||||
val jdkHome = when (jvmTarget) {
|
||||
JvmTarget.JVM_1_6 -> KtTestUtil.getJdk6Home()
|
||||
JvmTarget.JVM_1_8 -> KtTestUtil.getJdk8Home()
|
||||
JvmTarget.JVM_9 -> KtTestUtil.getJdk9Home()
|
||||
JvmTarget.JVM_11 -> KtTestUtil.getJdk11Home()
|
||||
JvmTarget.JVM_15 -> KtTestUtil.getJdk15Home()
|
||||
|
||||
@@ -35,7 +35,7 @@ interface CustomJdkTestLauncher {
|
||||
|
||||
fun doTestWithJdk11(mainClass: Class<*>, arg: String) {
|
||||
if (isJava9OrLater()) return
|
||||
KtTestUtil.getJdk11Home()?.let { doTestCustomJdk(mainClass, arg, it) }
|
||||
KtTestUtil.getJdk11Home().let { doTestCustomJdk(mainClass, arg, it) }
|
||||
}
|
||||
|
||||
private fun doTestCustomJdk(mainClass: Class<*>, arg: String, javaHome: File) {
|
||||
|
||||
Reference in New Issue
Block a user