Support additional flags in MPP tests. Add diagnostic tests for defaults
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
package base
|
||||
|
||||
interface Check {
|
||||
fun test(): String {
|
||||
return "fail";
|
||||
}
|
||||
}
|
||||
|
||||
open class CheckClass : Check
|
||||
@@ -0,0 +1,9 @@
|
||||
import base.*
|
||||
|
||||
interface SubCheck : Check {
|
||||
override fun test(): String {
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
class <!EXPLICIT_OVERRIDE_REQUIRED_IN_MIXED_MODE("public open fun test(): String defined in SubCheckClass", "public open fun test(): String defined in base.CheckClass", "all-compatibility")!>SubCheckClass<!> : CheckClass(), SubCheck
|
||||
@@ -0,0 +1,4 @@
|
||||
MODULE base { platform=[JVM]; root=base; additionalCompilerArgs=-Xjvm-default=disable }
|
||||
MODULE clash { platform=[JVM]; root=clash; additionalCompilerArgs=-Xjvm-default=all-compatibility }
|
||||
|
||||
clash -> base { kind=DEPENDS_ON }
|
||||
Generated
+5
@@ -153,6 +153,11 @@ public class MultiplatformAnalysisTestGenerated extends AbstractMultiplatformAna
|
||||
runTest("idea/testData/multiplatform/jsNameClash/");
|
||||
}
|
||||
|
||||
@TestMetadata("jvmDefaultNonMpp")
|
||||
public void testJvmDefaultNonMpp() throws Exception {
|
||||
runTest("idea/testData/multiplatform/jvmDefaultNonMpp/");
|
||||
}
|
||||
|
||||
@TestMetadata("lambdas")
|
||||
public void testLambdas() throws Exception {
|
||||
runTest("idea/testData/multiplatform/lambdas/");
|
||||
|
||||
@@ -115,7 +115,7 @@ fun AbstractMultiModuleTest.doSetup(projectModel: ProjectResolveModel) {
|
||||
pureKotlinSourceFolders = pureKotlinSourceFolders
|
||||
)
|
||||
// New inference is enabled here as these tests are using type refinement feature that is working only along with NI
|
||||
ideaModule.enableMultiPlatform(additionalCompilerArguments = "-Xnew-inference")
|
||||
ideaModule.enableMultiPlatform(additionalCompilerArguments = "-Xnew-inference " + (resolveModule.additionalCompilerArgs ?: ""))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,8 @@ open class ResolveModule(
|
||||
val root: File,
|
||||
val platform: TargetPlatform,
|
||||
val dependencies: List<ResolveDependency>,
|
||||
val testRoot: File? = null
|
||||
val testRoot: File? = null,
|
||||
val additionalCompilerArgs: String? = null
|
||||
) {
|
||||
final override fun toString(): String {
|
||||
return buildString { renderDescription(Printer(this)) }
|
||||
@@ -43,6 +44,7 @@ open class ResolveModule(
|
||||
printer.println("root=${root.absolutePath}")
|
||||
if (testRoot != null) printer.println("testRoot=${testRoot.absolutePath}")
|
||||
printer.println("dependencies=${dependencies.joinToString { it.to.name }}")
|
||||
if (additionalCompilerArgs != null) printer.println("additionalCompilerArgs=$additionalCompilerArgs")
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
@@ -69,6 +71,7 @@ open class ResolveModule(
|
||||
var platform: TargetPlatform? = null
|
||||
val dependencies: MutableList<ResolveDependency.Builder> = mutableListOf()
|
||||
var testRoot: File? = null
|
||||
var additionalCompilerArgs: String? = null
|
||||
|
||||
open fun build(): ResolveModule {
|
||||
if (state == State.BUILT) return cachedResult!!
|
||||
@@ -77,7 +80,7 @@ open class ResolveModule(
|
||||
state = State.BUILDING
|
||||
|
||||
val builtDependencies = dependencies.map { it.build() }
|
||||
cachedResult = ResolveModule(name!!, root!!, platform!!, builtDependencies, testRoot)
|
||||
cachedResult = ResolveModule(name!!, root!!, platform!!, builtDependencies, testRoot, additionalCompilerArgs= additionalCompilerArgs)
|
||||
state = State.BUILT
|
||||
|
||||
return cachedResult!!
|
||||
|
||||
@@ -70,6 +70,8 @@ open class ProjectStructureParser(private val projectRoot: File) {
|
||||
val root = attributes["root"] ?: builder.name!!
|
||||
builder.root = File(projectRoot, root)
|
||||
|
||||
builder.additionalCompilerArgs = attributes["additionalCompilerArgs"]
|
||||
|
||||
val testRoot = attributes["testRoot"]
|
||||
if (testRoot != null) builder.testRoot = File(projectRoot, testRoot)
|
||||
}
|
||||
@@ -116,7 +118,7 @@ open class ProjectStructureParser(private val projectRoot: File) {
|
||||
|
||||
return attributesString
|
||||
.split(ATTRIBUTES_SEPARATOR)
|
||||
.map { it.splitIntoExactlyTwoParts(ATTRIBUTE_VALUE_SEPARATOR) }
|
||||
.map { it.splitIntoTwoParts(ATTRIBUTE_VALUE_SEPARATOR) }
|
||||
.toMap()
|
||||
}
|
||||
|
||||
@@ -202,8 +204,10 @@ private fun Reader.nextWord(): String? {
|
||||
|
||||
private fun Char.isSeparator() = isWhitespace() || this == '\n'
|
||||
|
||||
private fun String.splitIntoExactlyTwoParts(separator: String): Pair<String, String> {
|
||||
private fun String.splitIntoTwoParts(separator: String): Pair<String, String> {
|
||||
val result = split(separator)
|
||||
require(result.size == 2) { "$this can not be split into exactly two parts with separator $separator" }
|
||||
return result[0].trim() to result[1].trim()
|
||||
val name = substringBefore(separator, "")
|
||||
val value = substringAfter(separator, "")
|
||||
require(name.isNotEmpty()) { "$this can not be split into two parts with separator $separator" }
|
||||
return name.trim() to value.trim()
|
||||
}
|
||||
Reference in New Issue
Block a user