Enable all Java 9 tests

This commit is contained in:
Alexander Udalov
2018-02-14 13:13:24 +01:00
parent 914cf18051
commit d2ed73eb78
7 changed files with 37 additions and 83 deletions
@@ -18,12 +18,9 @@ package org.jetbrains.kotlin.checkers;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.test.ConfigurationKind;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.TestJdkKind;
import java.io.File;
import java.util.List;
import java.util.Map;
public abstract class AbstractDiagnosticsWithJdk9Test extends AbstractDiagnosticsTest {
@NotNull
@@ -37,17 +34,4 @@ public abstract class AbstractDiagnosticsWithJdk9Test extends AbstractDiagnostic
protected TestJdkKind getTestJdkKind(@NotNull File file) {
return TestJdkKind.FULL_JDK_9;
}
@Override
protected void doMultiFileTest(
@NotNull File file,
@NotNull Map<String, ModuleAndDependencies> modules,
@NotNull List<TestFile> testFiles
) {
if (KotlinTestUtils.getJdk9HomeIfPossible() == null) {
// Skip this test if no Java 9 is found
return;
}
super.doMultiFileTest(file, modules, testFiles);
}
}
@@ -560,10 +560,7 @@ public class KotlinTestUtils {
configuration.put(JVMConfigurationKeys.JDK_HOME, new File(jdk6));
}
else if (jdkKind == TestJdkKind.FULL_JDK_9) {
File home = getJdk9HomeIfPossible();
if (home != null) {
configuration.put(JVMConfigurationKeys.JDK_HOME, home);
}
configuration.put(JVMConfigurationKeys.JDK_HOME, getJdk9Home());
}
else if (SystemInfo.IS_AT_LEAST_JAVA9) {
configuration.put(JVMConfigurationKeys.JDK_HOME, new File(System.getProperty("java.home")));
@@ -587,26 +584,18 @@ public class KotlinTestUtils {
return configuration;
}
@Nullable
public static File getJdk9HomeIfPossible() {
String jdk9 = System.getenv("JDK_19");
@NotNull
public static File getJdk9Home() {
String jdk9 = System.getenv("JDK_9");
if (jdk9 == null) {
jdk9 = System.getenv("JDK_9");
}
if (jdk9 == null) {
// TODO: replace this with a failure as soon as Java 9 is installed on all TeamCity agents
System.err.println("Environment variable JDK_19 is not set, the test will be skipped");
return null;
jdk9 = System.getenv("JDK_19");
if (jdk9 == null) {
throw new AssertionError("Environment variable JDK_9 is not set!");
}
}
return new File(jdk9);
}
@NotNull
private static String getJreHome(@NotNull String jdkHome) {
File jre = new File(jdkHome, "jre");
return jre.isDirectory() ? jre.getPath() : jdkHome;
}
public static void resolveAllKotlinFiles(KotlinCoreEnvironment environment) throws IOException {
List<String> paths = ContentRootsKt.getKotlinSourceRoots(environment.getConfiguration());
if (paths.isEmpty()) return;
@@ -982,11 +971,8 @@ public class KotlinTestUtils {
}
public static boolean compileJavaFilesExternallyWithJava9(@NotNull Collection<File> files, @NotNull List<String> options) {
File jdk9 = getJdk9HomeIfPossible();
assert jdk9 != null : "Environment variable JDK_19 is not set";
List<String> command = new ArrayList<>();
command.add(new File(jdk9, "bin/javac").getPath());
command.add(new File(getJdk9Home(), "bin/javac").getPath());
command.addAll(options);
for (File file : files) {
command.add(file.getPath());