MPP: test different jvm implementations for single common module

Add test infrastructure to support same platform implementations
This commit is contained in:
Pavel V. Talanov
2018-08-20 16:55:20 +02:00
parent cb8951eeef
commit 7087a1b3f5
12 changed files with 96 additions and 7 deletions
@@ -0,0 +1,3 @@
package common
expect class A
@@ -0,0 +1,10 @@
package j1;
import common.A;
public class Use {
public static void use() {
A a = new A();
a.id1();
}
}
@@ -0,0 +1,5 @@
package common
actual class A {
fun id1() {}
}
@@ -0,0 +1,10 @@
package j2;
import common.A;
public class Use {
public static void use() {
A a = new A();
a.id2();
}
}
@@ -0,0 +1,5 @@
package common
actual class A {
fun id2() {}
}
@@ -0,0 +1,9 @@
package j;
import common.A;
public class Use {
public static void use(A a) {
a.id2();
}
}
@@ -0,0 +1,7 @@
package b
import common.A
fun use(a: A) {
a.id2()
}
@@ -0,0 +1,9 @@
package j;
import common.A;
public class Use {
public static void use(A a) {
a.id1();
}
}
@@ -0,0 +1,7 @@
package c
import common.A
fun use(a: A) {
a.id1()
}
@@ -49,6 +49,11 @@ public class MultiPlatformHighlightingTestGenerated extends AbstractMultiPlatfor
runTest("idea/testData/multiModuleHighlighting/multiplatform/depends/");
}
@TestMetadata("differentJvmImpls")
public void testDifferentJvmImpls() throws Exception {
runTest("idea/testData/multiModuleHighlighting/multiplatform/differentJvmImpls/");
}
@TestMetadata("headerClass")
public void testHeaderClass() throws Exception {
runTest("idea/testData/multiModuleHighlighting/multiplatform/headerClass/");
@@ -11,7 +11,6 @@ import com.intellij.openapi.module.StdModuleTypes
import com.intellij.openapi.roots.CompilerModuleExtension
import com.intellij.openapi.roots.ModuleRootModificationUtil
import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.testFramework.PlatformTestCase
import junit.framework.TestCase
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
import org.jetbrains.kotlin.config.JvmTarget
@@ -154,7 +153,9 @@ private fun parseDependency(it: String): Dependency {
private fun parseModuleId(parts: List<String>): ModuleId {
val platform = parsePlatform(parts)
val name = parseModuleName(parts)
return ModuleId(name, platform)
val id = parseIndex(parts) ?: 0
assert(id == 0 || platform !is TargetPlatformKind.Common)
return ModuleId(name, platform, id)
}
private fun parsePlatform(parts: List<String>) =
@@ -170,11 +171,19 @@ private fun parseModuleName(parts: List<String>) = when {
private fun parseIsTestRoot(parts: List<String>) =
testSuffixes.any { suffix -> parts.any { it.equals(suffix, ignoreCase = true) } }
private fun parseIndex(parts: List<String>): Int? {
return parts.singleOrNull() { it.startsWith("id") }?.substringAfter("id")?.toInt()
}
private data class ModuleId(
val groupName: String,
val platform: TargetPlatformKind<*>
val platform: TargetPlatformKind<*>,
val index: Int = 0
) {
fun ideaModuleName() = "${groupName}_${platform.presentableName}"
fun ideaModuleName(): String {
val suffix = "_$index".takeIf { index != 0 } ?: ""
return "${groupName}_${platform.presentableName}$suffix"
}
}
private val TargetPlatformKind<*>.presentableName: String
@@ -154,7 +154,9 @@ private fun parseDependency(it: String): Dependency {
private fun parseModuleId(parts: List<String>): ModuleId {
val platform = parsePlatform(parts)
val name = parseModuleName(parts)
return ModuleId(name, platform)
val id = parseIndex(parts) ?: 0
assert(id == 0 || platform !is TargetPlatformKind.Common)
return ModuleId(name, platform, id)
}
private fun parsePlatform(parts: List<String>) =
@@ -170,11 +172,19 @@ private fun parseModuleName(parts: List<String>) = when {
private fun parseIsTestRoot(parts: List<String>) =
testSuffixes.any { suffix -> parts.any { it.equals(suffix, ignoreCase = true) } }
private fun parseIndex(parts: List<String>): Int? {
return parts.singleOrNull() { it.startsWith("id") }?.substringAfter("id")?.toInt()
}
private data class ModuleId(
val groupName: String,
val platform: TargetPlatformKind<*>
val platform: TargetPlatformKind<*>,
val index: Int = 0
) {
fun ideaModuleName() = "${groupName}_${platform.presentableName}"
fun ideaModuleName(): String {
val suffix = "_$index".takeIf { index != 0 } ?: ""
return "${groupName}_${platform.presentableName}$suffix"
}
}
private val TargetPlatformKind<*>.presentableName: String