Configure sdk properly in configure Kotlin tests
This commit is contained in:
@@ -16,9 +16,13 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.test;
|
||||
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.projectRoots.JavaSdk;
|
||||
import com.intellij.openapi.projectRoots.ProjectJdkTable;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -56,6 +60,17 @@ public class PluginTestCaseBase {
|
||||
return getSdk("compiler/testData/mockJDK/jre", "Mock JDK");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Sdk mockJdk6() {
|
||||
return getSdk("compiler/testData/mockJDK/jre", "1.6");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Sdk mockJdk8() {
|
||||
// Using JDK 6, but with version 1.8
|
||||
return getSdk("compiler/testData/mockJDK/jre", "1.8");
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
@NotNull
|
||||
public static Sdk mockJdk9() {
|
||||
@@ -89,4 +104,14 @@ public class PluginTestCaseBase {
|
||||
public static boolean isAllFilesPresentTest(@NotNull String testName) {
|
||||
return StringUtil.startsWithIgnoreCase(testName, "allFilesPresentIn");
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public static void clearSdkTable(@NotNull Disposable disposable) {
|
||||
Disposer.register(disposable, () -> ApplicationManager.getApplication().runWriteAction(() -> {
|
||||
ProjectJdkTable jdkTable = ProjectJdkTable.getInstance();
|
||||
for (Sdk sdk : jdkTable.getAllJdks()) {
|
||||
jdkTable.removeJdk(sdk);
|
||||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user