tests fixed

This commit is contained in:
Dmitry Jemerov
2016-01-14 18:45:09 +01:00
parent 39c6e3712b
commit b60621c428
24 changed files with 52 additions and 35 deletions
@@ -35,21 +35,23 @@ public class JdkAndMockLibraryProjectDescriptor extends KotlinLightProjectDescri
private final boolean withSources;
private final boolean withRuntime;
private final boolean isJsLibrary;
private final boolean allowKotlinPackage;
public JdkAndMockLibraryProjectDescriptor(String sourcesPath, boolean withSources) {
this(sourcesPath, withSources, false, false);
this(sourcesPath, withSources, false, false, false);
}
public JdkAndMockLibraryProjectDescriptor(String sourcesPath, boolean withSources, boolean withRuntime, boolean isJsLibrary) {
public JdkAndMockLibraryProjectDescriptor(String sourcesPath, boolean withSources, boolean withRuntime, boolean isJsLibrary, boolean allowKotlinPackage) {
this.sourcesPath = sourcesPath;
this.withSources = withSources;
this.withRuntime = withRuntime;
this.isJsLibrary = isJsLibrary;
this.allowKotlinPackage = allowKotlinPackage;
}
@Override
public void configureModule(@NotNull Module module, @NotNull ModifiableRootModel model) {
File libraryJar = MockLibraryUtil.compileLibraryToJar(sourcesPath, LIBRARY_NAME, withSources, isJsLibrary);
File libraryJar = MockLibraryUtil.compileLibraryToJar(sourcesPath, LIBRARY_NAME, withSources, isJsLibrary, allowKotlinPackage);
String jarUrl = getJarUrl(libraryJar);
Library.ModifiableModel libraryModel = model.getModuleLibraryTable().getModifiableModel().createLibrary(LIBRARY_NAME).getModifiableModel();
@@ -32,7 +32,7 @@ abstract class AbstractJavaAgainstKotlinBinariesCheckerTest : AbstractJavaAgains
val libraryName = "libFor" + testName
val libraryJar = MockLibraryUtil.compileLibraryToJar(
PluginTestCaseBase.getTestDataPathBase() + "/kotlinAndJavaChecker/javaAgainstKotlin/" + getTestName(false) + ".kt",
libraryName, false, false
libraryName, false, false, false
)
val jarUrl = "jar://" + FileUtilRt.toSystemIndependentName(libraryJar.absolutePath) + "!/"
ModuleRootModificationUtil.addModuleLibrary(module, jarUrl)
@@ -51,7 +51,7 @@ abstract class AbstractIdeCompiledLightClassTest : KotlinDaemonAnalyzerTestCase(
Assert.assertTrue("File doesn't exist $filePath", File(filePath).exists())
val libraryJar = MockLibraryUtil.compileLibraryToJar(filePath, libName(), false, false)
val libraryJar = MockLibraryUtil.compileLibraryToJar(filePath, libName(), false, false, false)
val jarUrl = "jar://" + FileUtilRt.toSystemIndependentName(libraryJar.absolutePath) + "!/"
ModuleRootModificationUtil.addModuleLibrary(module, jarUrl)
}
@@ -34,8 +34,8 @@ class HighlightingWithDependentLibrariesTest : KotlinLightCodeInsightFixtureTest
override fun getProjectDescriptor() = object : KotlinLightProjectDescriptor() {
override fun configureModule(module: Module, model: ModifiableRootModel) {
val compiledJar1 = MockLibraryUtil.compileLibraryToJar("$TEST_DATA_PATH/lib1", "lib1", false)
val compiledJar2 = MockLibraryUtil.compileLibraryToJar("$TEST_DATA_PATH/lib2", "lib2", false, compiledJar1.canonicalPath)
val compiledJar1 = MockLibraryUtil.compileLibraryToJar("$TEST_DATA_PATH/lib1", "lib1", false, false)
val compiledJar2 = MockLibraryUtil.compileLibraryToJar("$TEST_DATA_PATH/lib2", "lib2", false, false, compiledJar1.canonicalPath)
model.addLibraryEntry(createLibrary(compiledJar1, "baseLibrary"))
model.addLibraryEntry(createLibrary(compiledJar2, "dependentLibrary"))
@@ -118,7 +118,8 @@ public abstract class KotlinDebuggerTestCase extends DescriptorTestCase {
if (!IS_TINY_APP_COMPILED) {
String modulePath = getTestAppPath();
CUSTOM_LIBRARY_JAR = MockLibraryUtil.compileLibraryToJar(CUSTOM_LIBRARY_SOURCES.getPath(), "debuggerCustomLibrary", false);
CUSTOM_LIBRARY_JAR = MockLibraryUtil.compileLibraryToJar(CUSTOM_LIBRARY_SOURCES.getPath(), "debuggerCustomLibrary", false,
false);
String outputDir = getAppOutputPath();
String sourcesDir = modulePath + File.separator + "src";
@@ -31,9 +31,7 @@ import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
import org.jetbrains.kotlin.psi.KtClass
import org.jetbrains.kotlin.psi.KtClassOrObject
import org.jetbrains.kotlin.utils.sure
import kotlin.test.assertEquals
import kotlin.test.assertTrue
import kotlin.test.fail
class NavigateFromLibrarySourcesTest: LightCodeInsightFixtureTestCase() {
fun testJdkClass() {
@@ -73,7 +71,7 @@ class NavigateFromLibrarySourcesTest: LightCodeInsightFixtureTestCase() {
}
override fun getProjectDescriptor(): LightProjectDescriptor {
return JdkAndMockLibraryProjectDescriptor(PluginTestCaseBase.getTestDataPathBase() + "/decompiler/navigation/fromLibSource", true, true, false)
return JdkAndMockLibraryProjectDescriptor(PluginTestCaseBase.getTestDataPathBase() + "/decompiler/navigation/fromLibSource", true, true, false, false)
}
private fun checkNavigationElement(element: PsiElement, expectedFqName: String) {
@@ -55,7 +55,7 @@ abstract class AbstractClsStubBuilderTest : LightCodeInsightFixtureTestCase() {
private fun getClassFileToDecompile(sourcePath: String): VirtualFile {
val outDir = KotlinTestUtils.tmpDir("libForStubTest-" + sourcePath)
MockLibraryUtil.compileKotlin(sourcePath, outDir)
MockLibraryUtil.compileKotlin(sourcePath, outDir, true)
val root = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(outDir)!!
return root.findClassFileByName(lastSegment(sourcePath))
}
@@ -32,7 +32,8 @@ import java.io.File
abstract class AbstractDecompiledTextBaseTest(
baseDirectory: String,
private val isJsLibrary: Boolean = false
private val isJsLibrary: Boolean = false,
private val allowKotlinPackage: Boolean = false
) : KotlinLightCodeInsightFixtureTestCase() {
protected val TEST_DATA_PATH: String = PluginTestCaseBase.getTestDataPathBase() + baseDirectory
@@ -54,7 +55,7 @@ abstract class AbstractDecompiledTextBaseTest(
if (isAllFilesPresentInTest()) {
return KotlinLightProjectDescriptor.INSTANCE
}
return JdkAndMockLibraryProjectDescriptor(TEST_DATA_PATH + "/" + getTestName(false), false, false, isJsLibrary)
return JdkAndMockLibraryProjectDescriptor(TEST_DATA_PATH + "/" + getTestName(false), false, false, isJsLibrary, allowKotlinPackage)
}
private fun checkThatFileWasParsedCorrectly(clsFile: PsiFile) {
@@ -22,7 +22,8 @@ import org.jetbrains.kotlin.idea.decompiler.classFile.KtClsFile
import org.jetbrains.kotlin.idea.decompiler.navigation.NavigateToDecompiledLibraryTest
import kotlin.test.assertTrue
abstract class AbstractDecompiledTextTest(baseDirectory: String) : AbstractDecompiledTextBaseTest(baseDirectory) {
abstract class AbstractDecompiledTextTest(baseDirectory: String, allowKotlinPackage: Boolean)
: AbstractDecompiledTextBaseTest(baseDirectory, allowKotlinPackage = allowKotlinPackage) {
override fun getFileToDecompile(): VirtualFile =
NavigateToDecompiledLibraryTest.getClassFile(TEST_PACKAGE, getTestName(false), myModule!!)
@@ -30,6 +31,6 @@ abstract class AbstractDecompiledTextTest(baseDirectory: String) : AbstractDecom
assertTrue(psiFile is KtClsFile, "Expecting decompiled kotlin file, was: " + psiFile.javaClass)
}
abstract class AbstractCommonDecompiledTextTest : AbstractDecompiledTextTest("/decompiler/decompiledText")
abstract class AbstractCommonDecompiledTextTest : AbstractDecompiledTextTest("/decompiler/decompiledText", true)
abstract class AbstractJvmDecompiledTextTest : AbstractDecompiledTextTest("/decompiler/decompiledTextJvm")
abstract class AbstractJvmDecompiledTextTest : AbstractDecompiledTextTest("/decompiler/decompiledTextJvm", false)
@@ -58,7 +58,7 @@ abstract class AbstractKotlinExceptionFilterTest: KotlinCodeInsightTestCase() {
val classLoader: URLClassLoader
if (InTextDirectivesUtils.getPrefixedBoolean(fileText, "// WITH_MOCK_LIBRARY: ") ?: false) {
if (MOCK_LIBRARY_JAR == null) {
MOCK_LIBRARY_JAR = MockLibraryUtil.compileLibraryToJar(MOCK_LIBRARY_SOURCES, "mockLibrary", true)
MOCK_LIBRARY_JAR = MockLibraryUtil.compileLibraryToJar(MOCK_LIBRARY_SOURCES, "mockLibrary", true, false)
}
val mockLibraryJar = MOCK_LIBRARY_JAR ?: throw AssertionError("Mock library JAR is null")
@@ -28,6 +28,6 @@ public abstract class AbstractReferenceResolveWithLibTest extends AbstractRefere
if (PluginTestCaseBase.isAllFilesPresentTest(getTestName(true))) {
return null;
}
return new JdkAndMockLibraryProjectDescriptor(TEST_DATA_PATH + "/" + getTestName(true) + "Src", false, true, false);
return new JdkAndMockLibraryProjectDescriptor(TEST_DATA_PATH + "/" + getTestName(true) + "Src", false, true, false, false);
}
}