fix tests
This commit is contained in:
committed by
Evgeny Gerashchenko
parent
715f4ad0db
commit
9d75359f55
@@ -68,11 +68,11 @@ public class KotlinSdkDescription extends CustomLibraryDescription {
|
|||||||
descriptor.setTitle("Kotlin SDK");
|
descriptor.setTitle("Kotlin SDK");
|
||||||
descriptor.setDescription("Choose a directory containing Kotlin distribution");
|
descriptor.setDescription("Choose a directory containing Kotlin distribution");
|
||||||
|
|
||||||
final VirtualFile sdkHome = FileChooser.chooseFile(parentComponent, descriptor, initial);
|
final VirtualFile sdkHomeVFile = FileChooser.chooseFile(parentComponent, descriptor, initial);
|
||||||
if (sdkHome == null) return null;
|
if (sdkHomeVFile == null) return null;
|
||||||
|
|
||||||
final String sdkHomePath = sdkHome.getPath();
|
final File sdkHome = new File(sdkHomeVFile.getPath());
|
||||||
final String sdkVersion = KotlinSdkUtil.getSDKVersion(new File(sdkHomePath));
|
final String sdkVersion = KotlinSdkUtil.getSDKVersion(sdkHome);
|
||||||
if (sdkVersion == null) {
|
if (sdkVersion == null) {
|
||||||
Messages.showErrorDialog(parentComponent,
|
Messages.showErrorDialog(parentComponent,
|
||||||
"Failed to find Kotlin SDK in the specified path: cannot determine Kotlin version.",
|
"Failed to find Kotlin SDK in the specified path: cannot determine Kotlin version.",
|
||||||
@@ -83,7 +83,7 @@ public class KotlinSdkDescription extends CustomLibraryDescription {
|
|||||||
return new NewLibraryConfiguration(KotlinSdkUtil.getSDKName(sdkVersion)) {
|
return new NewLibraryConfiguration(KotlinSdkUtil.getSDKName(sdkVersion)) {
|
||||||
@Override
|
@Override
|
||||||
public void addRoots(@NotNull final LibraryEditor editor) {
|
public void addRoots(@NotNull final LibraryEditor editor) {
|
||||||
addSDKRoots(editor, sdkHomePath);
|
addSDKRoots(editor, sdkHome);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -95,8 +95,8 @@ public class KotlinSdkDescription extends CustomLibraryDescription {
|
|||||||
return LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(path));
|
return LocalFileSystem.getInstance().findFileByPath(FileUtil.toSystemIndependentName(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void addSDKRoots(@NotNull final LibraryEditor editor, @NotNull final String sdkHomePath) {
|
public static void addSDKRoots(@NotNull final LibraryEditor editor, @NotNull final File sdkHome) {
|
||||||
final File libDir = new File(sdkHomePath, "lib");
|
final File libDir = new File(sdkHome, "lib");
|
||||||
if (!libDir.isDirectory()) return;
|
if (!libDir.isDirectory()) return;
|
||||||
|
|
||||||
final List<File> jars = new ArrayList<File>();
|
final List<File> jars = new ArrayList<File>();
|
||||||
|
|||||||
@@ -22,13 +22,19 @@ import com.intellij.openapi.compiler.TranslatingCompiler;
|
|||||||
import com.intellij.openapi.roots.ContentEntry;
|
import com.intellij.openapi.roots.ContentEntry;
|
||||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||||
import com.intellij.openapi.roots.ModuleRootManager;
|
import com.intellij.openapi.roots.ModuleRootManager;
|
||||||
|
import com.intellij.openapi.roots.libraries.Library;
|
||||||
|
import com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor;
|
||||||
|
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainer;
|
||||||
|
import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainerFactory;
|
||||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||||
import com.intellij.openapi.vfs.VirtualFile;
|
import com.intellij.openapi.vfs.VirtualFile;
|
||||||
import com.intellij.testFramework.PlatformTestCase;
|
import com.intellij.testFramework.PlatformTestCase;
|
||||||
import jet.Function1;
|
import jet.Function1;
|
||||||
import junit.framework.Assert;
|
import junit.framework.Assert;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.jet.plugin.sdk.KotlinSdkDescription;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,6 +55,7 @@ public abstract class IDECompilerMessagingTest extends PlatformTestCase {
|
|||||||
MockCompileContext mockCompileContext = new MockCompileContext(myModule, outDirectory, root);
|
MockCompileContext mockCompileContext = new MockCompileContext(myModule, outDirectory, root);
|
||||||
MockModuleChunk mockModuleChunk = new MockModuleChunk(myModule);
|
MockModuleChunk mockModuleChunk = new MockModuleChunk(myModule);
|
||||||
setSourceEntryForModule(root);
|
setSourceEntryForModule(root);
|
||||||
|
setKotlinSdkForModule();
|
||||||
assert sampleFile != null;
|
assert sampleFile != null;
|
||||||
compile(compiler, sampleFile, mockCompileContext, mockModuleChunk);
|
compile(compiler, sampleFile, mockCompileContext, mockModuleChunk);
|
||||||
checkMessages(whatToExpect, mockCompileContext);
|
checkMessages(whatToExpect, mockCompileContext);
|
||||||
@@ -80,6 +87,25 @@ public abstract class IDECompilerMessagingTest extends PlatformTestCase {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setKotlinSdkForModule() {
|
||||||
|
ApplicationManager.getApplication().runWriteAction(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
final ModifiableRootModel model = ModuleRootManager.getInstance(myModule).getModifiableModel();
|
||||||
|
model.addLibraryEntry(createKotlinSdkLibrary());
|
||||||
|
model.commit();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private Library createKotlinSdkLibrary() {
|
||||||
|
final NewLibraryEditor editor = new NewLibraryEditor();
|
||||||
|
editor.setName("Kotlin SDK");
|
||||||
|
KotlinSdkDescription.addSDKRoots(editor, new File("dist/kotlinc"));
|
||||||
|
return LibrariesContainerFactory.createContainer(myModule).createLibrary(editor, LibrariesContainer.LibraryLevel.GLOBAL);
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract void checkHeader(@NotNull MessageChecker checker);
|
protected abstract void checkHeader(@NotNull MessageChecker checker);
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
Reference in New Issue
Block a user