Skip to content

Commit f958bd5

Browse files
committed
Fix sdk-aware tests on IDEA 15 EAP
1 parent ab583b1 commit f958bd5

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

tests/com/goide/GoCodeInsightFixtureTestCase.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818

1919
import com.goide.project.GoApplicationLibrariesService;
2020
import com.goide.sdk.GoSdkType;
21+
import com.goide.sdk.GoSdkUtil;
2122
import com.intellij.openapi.application.ApplicationManager;
2223
import com.intellij.openapi.module.ModuleType;
2324
import com.intellij.openapi.projectRoots.ProjectJdkTable;
2425
import com.intellij.openapi.projectRoots.Sdk;
2526
import com.intellij.openapi.projectRoots.SdkModificator;
2627
import com.intellij.openapi.projectRoots.impl.ProjectJdkImpl;
28+
import com.intellij.openapi.roots.OrderRootType;
2729
import com.intellij.openapi.roots.ProjectRootManager;
2830
import com.intellij.openapi.util.text.StringUtil;
2931
import com.intellij.openapi.vfs.VfsUtilCore;
@@ -55,10 +57,10 @@ protected static DefaultLightProjectDescriptor createMockProjectDescriptor() {
5557
return new DefaultLightProjectDescriptor() {
5658
@Override
5759
public Sdk getSdk() {
58-
String version = "1.1.2";
59-
return createMockSdk("testData/mockSdk-" + version + "/", version);
60+
return createMockSdk("1.1.2");
6061
}
6162

63+
@NotNull
6264
@Override
6365
public ModuleType getModuleType() {
6466
return GoModuleType.getInstance();
@@ -78,15 +80,17 @@ public void run() {
7880
}
7981

8082
@NotNull
81-
private static Sdk createMockSdk(@NotNull String sdkHome, @NotNull String version) {
82-
GoSdkType instance = GoSdkType.getInstance();
83-
String release = "Go " + version;
84-
Sdk sdk = new ProjectJdkImpl(release, instance);
83+
private static Sdk createMockSdk(@NotNull String version) {
84+
Sdk sdk = new ProjectJdkImpl("Go " + version, GoSdkType.getInstance());
8585
SdkModificator sdkModificator = sdk.getSdkModificator();
86-
sdkModificator.setHomePath(sdkHome);
86+
87+
String homePath = new File("testData/mockSdk-" + version + "/").getAbsolutePath();
88+
sdkModificator.setHomePath(homePath);
8789
sdkModificator.setVersionString(version); // must be set after home path, otherwise setting home path clears the version string
90+
for (VirtualFile file : GoSdkUtil.getSdkDirectoriesToAttach(homePath, version)) {
91+
sdkModificator.addRoot(file, OrderRootType.CLASSES);
92+
}
8893
sdkModificator.commitChanges();
89-
instance.setupSdkPaths(sdk);
9094
return sdk;
9195
}
9296

0 commit comments

Comments
 (0)