tests fixed
This commit is contained in:
@@ -7,4 +7,4 @@ java.lang.IllegalStateException: my error
|
||||
at Script.a(Unknown Source)
|
||||
at Script.<init>(Unknown Source)
|
||||
|
||||
Return code: 0
|
||||
Return code: 3
|
||||
|
||||
@@ -30,7 +30,7 @@ abstract class AbstractForeignAnnotationsTest : AbstractDiagnosticsTest() {
|
||||
override fun createCompilerConfiguration(javaFilesDir: File?): CompilerConfiguration {
|
||||
val annotationsFile = MockLibraryUtil.compileLibraryToJar(
|
||||
"compiler/testData/foreignAnnotations/annotations",
|
||||
"foreign-annotations", /* addSources = */false)
|
||||
"foreign-annotations", /* addSources = */false, /* allowKotlinPackage =*/ false)
|
||||
|
||||
return KotlinTestUtils.compilerConfigurationForTests(
|
||||
ConfigurationKind.JDK_ONLY,
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public abstract class AbstractTopLevelMembersInvocationTest extends AbstractByte
|
||||
|
||||
File library = new File(root, LIBRARY);
|
||||
List<File> classPath = library.exists() ?
|
||||
Collections.singletonList(MockLibraryUtil.compileLibraryToJar(library.getPath(), LIBRARY, false)) :
|
||||
Collections.singletonList(MockLibraryUtil.compileLibraryToJar(library.getPath(), LIBRARY, false, false)) :
|
||||
Collections.<File>emptyList();
|
||||
|
||||
assert !sourceFiles.isEmpty() : getTestName(true) + " should contain at least one .kt file";
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
||||
@NotNull
|
||||
private File compileLibrary(@NotNull String sourcePath, @NotNull String... extraClassPath) {
|
||||
return MockLibraryUtil.compileLibraryToJar(
|
||||
new File(getTestDataDirectory(), sourcePath).getPath(), "customKotlinLib", false, extraClassPath
|
||||
new File(getTestDataDirectory(), sourcePath).getPath(), "customKotlinLib", false, false, extraClassPath
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,13 +53,14 @@ public class MockLibraryUtil {
|
||||
@NotNull String jarName,
|
||||
boolean addSources,
|
||||
boolean isJsLibrary,
|
||||
boolean allowKotlinPackage,
|
||||
@NotNull String... extraClasspath
|
||||
) {
|
||||
if (isJsLibrary) {
|
||||
return compileJsLibraryToJar(sourcesPath, jarName, addSources);
|
||||
}
|
||||
else {
|
||||
return compileLibraryToJar(sourcesPath, jarName, addSources, extraClasspath);
|
||||
return compileLibraryToJar(sourcesPath, jarName, addSources, allowKotlinPackage, extraClasspath);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,6 +69,7 @@ public class MockLibraryUtil {
|
||||
@NotNull String sourcesPath,
|
||||
@NotNull String jarName,
|
||||
boolean addSources,
|
||||
boolean allowKotlinPackage,
|
||||
@NotNull String... extraClasspath
|
||||
) {
|
||||
try {
|
||||
@@ -78,7 +80,7 @@ public class MockLibraryUtil {
|
||||
File srcFile = new File(sourcesPath);
|
||||
List<File> kotlinFiles = FileUtil.findFilesByMask(Pattern.compile(".*\\.kt"), srcFile);
|
||||
if (srcFile.isFile() || !kotlinFiles.isEmpty()) {
|
||||
compileKotlin(sourcesPath, classesDir, extraClasspath);
|
||||
compileKotlin(sourcesPath, classesDir, allowKotlinPackage, extraClasspath);
|
||||
}
|
||||
|
||||
List<File> javaFiles = FileUtil.findFilesByMask(Pattern.compile(".*\\.java"), srcFile);
|
||||
@@ -170,6 +172,15 @@ public class MockLibraryUtil {
|
||||
}
|
||||
|
||||
public static void compileKotlin(@NotNull String sourcesPath, @NotNull File outDir, @NotNull String... extraClasspath) {
|
||||
compileKotlin(sourcesPath, outDir, false, extraClasspath);
|
||||
}
|
||||
|
||||
public static void compileKotlin(
|
||||
@NotNull String sourcesPath,
|
||||
@NotNull File outDir,
|
||||
boolean allowKotlinPackage,
|
||||
@NotNull String... extraClasspath
|
||||
) {
|
||||
List<String> classpath = new ArrayList<String>();
|
||||
if (new File(sourcesPath).isDirectory()) {
|
||||
classpath.add(sourcesPath);
|
||||
@@ -182,6 +193,9 @@ public class MockLibraryUtil {
|
||||
args.add(outDir.getAbsolutePath());
|
||||
args.add("-classpath");
|
||||
args.add(StringUtil.join(classpath, File.pathSeparator));
|
||||
if (allowKotlinPackage) {
|
||||
args.add("-Xallow-kotlin-package");
|
||||
}
|
||||
|
||||
runJvmCompiler(args);
|
||||
}
|
||||
|
||||
+5
-3
@@ -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();
|
||||
|
||||
+1
-1
@@ -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)
|
||||
}
|
||||
|
||||
+2
-2
@@ -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";
|
||||
|
||||
+1
-3
@@ -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) {
|
||||
|
||||
+1
-1
@@ -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))
|
||||
}
|
||||
|
||||
+3
-2
@@ -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) {
|
||||
|
||||
+4
-3
@@ -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")
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -551,7 +551,7 @@ class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
||||
fun testCircularDependencyWithReferenceToOldVersionLib() {
|
||||
initProject()
|
||||
|
||||
val libraryJar = MockLibraryUtil.compileLibraryToJar(workDir.absolutePath + File.separator + "oldModuleLib/src", "module-lib", false)
|
||||
val libraryJar = MockLibraryUtil.compileLibraryToJar(workDir.absolutePath + File.separator + "oldModuleLib/src", "module-lib", false, false)
|
||||
|
||||
AbstractKotlinJpsBuildTestCase.addDependency(JpsJavaDependencyScope.COMPILE, Lists.newArrayList(findModule("module1"), findModule("module2")), false, "module-lib", libraryJar)
|
||||
|
||||
@@ -562,7 +562,7 @@ class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
|
||||
fun testDependencyToOldKotlinLib() {
|
||||
initProject()
|
||||
|
||||
val libraryJar = MockLibraryUtil.compileLibraryToJar(workDir.absolutePath + File.separator + "oldModuleLib/src", "module-lib", false)
|
||||
val libraryJar = MockLibraryUtil.compileLibraryToJar(workDir.absolutePath + File.separator + "oldModuleLib/src", "module-lib", false, false)
|
||||
|
||||
AbstractKotlinJpsBuildTestCase.addDependency(JpsJavaDependencyScope.COMPILE, Lists.newArrayList(findModule("module")), false, "module-lib", libraryJar)
|
||||
|
||||
|
||||
@@ -2,6 +2,6 @@ package java;
|
||||
|
||||
public class JFirst {
|
||||
public void foo() {
|
||||
new kotlin.KFirst().foo();
|
||||
new myproject.kotlin.KFirst().foo();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package kotlin
|
||||
package myproject.kotlin
|
||||
|
||||
class KFirst() {
|
||||
fun foo() {
|
||||
|
||||
@@ -2,10 +2,10 @@ package java;
|
||||
|
||||
public class JFirst {
|
||||
public void foo() {
|
||||
new kotlin.KFirst().foo();
|
||||
new myproject.kotlin.KFirst().foo();
|
||||
}
|
||||
|
||||
public void bar() {
|
||||
new kotlin.KFirst().bar();
|
||||
new myproject.kotlin.KFirst().bar();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package kotlin
|
||||
package myproject.kotlin
|
||||
|
||||
class KFirst() {
|
||||
fun foo() {
|
||||
|
||||
@@ -2,6 +2,6 @@ package java;
|
||||
|
||||
public class JFirst {
|
||||
public void foo() {
|
||||
new kotlin.KSecond().foo();
|
||||
new myproject.kotlin.KSecond().foo();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package kotlin
|
||||
package myproject.kotlin
|
||||
|
||||
class KFirst() {
|
||||
fun foo() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package kotlin
|
||||
package myproject.kotlin
|
||||
|
||||
class KSecond() {
|
||||
fun foo() {
|
||||
|
||||
Reference in New Issue
Block a user