[MPP] Fix NewMultiplatformIT and make it run on arm macOS
^KT-58822
This commit is contained in:
committed by
Space Team
parent
f467c970b2
commit
d6d1ed6c35
+9
-1
@@ -830,6 +830,14 @@ abstract class BaseGradleIT {
|
||||
fun CompiledProject.assertTestResults(
|
||||
@TestDataFile assertionFileName: String,
|
||||
vararg testReportNames: String
|
||||
) = assertTestResults(
|
||||
resourcesRootFile.resolve(assertionFileName),
|
||||
*testReportNames
|
||||
)
|
||||
|
||||
fun CompiledProject.assertTestResults(
|
||||
assertionXmlFile: File,
|
||||
vararg testReportNames: String
|
||||
) {
|
||||
val projectDir = project.projectDir
|
||||
val testReportDirs = testReportNames.map { projectDir.resolve("build/test-results/$it").toPath() }
|
||||
@@ -844,7 +852,7 @@ abstract class BaseGradleIT {
|
||||
val excl = "Invalid connection: com.apple.coresymbolicationd"
|
||||
s.lines().filter { it != excl }.joinToString("\n")
|
||||
}
|
||||
val expectedTestResults = prettyPrintXml(resourcesRootFile.resolve(assertionFileName).readText())
|
||||
val expectedTestResults = prettyPrintXml(assertionXmlFile.readText())
|
||||
|
||||
assertEquals(expectedTestResults, actualTestResults)
|
||||
}
|
||||
|
||||
+18
-15
@@ -22,11 +22,10 @@ import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinMultiplatformPlugin
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.METADATA_CONFIGURATION_NAME_SUFFIX
|
||||
import org.jetbrains.kotlin.gradle.plugin.sources.UnsatisfiedSourceSetVisibilityException
|
||||
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
|
||||
import org.jetbrains.kotlin.gradle.testbase.TestVersions
|
||||
import org.jetbrains.kotlin.gradle.testbase.assertHasDiagnostic
|
||||
import org.jetbrains.kotlin.gradle.testbase.assertNoDiagnostic
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.jetbrains.kotlin.gradle.util.*
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
import org.jetbrains.kotlin.library.KLIB_PROPERTY_SHORT_NAME
|
||||
import org.jetbrains.kotlin.library.KLIB_PROPERTY_UNIQUE_NAME
|
||||
import org.junit.Assert
|
||||
@@ -688,6 +687,14 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
private val targetName = when (HostManager.host) {
|
||||
KonanTarget.LINUX_X64 -> "linux64"
|
||||
KonanTarget.MACOS_X64 -> "macos64"
|
||||
KonanTarget.MACOS_ARM64 -> "macosArm64"
|
||||
KonanTarget.MINGW_X64 -> "mingw64"
|
||||
else -> fail("Unsupported host")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLibWithTests() = doTestLibWithTests(transformNativeTestProject("new-mpp-lib-with-tests", gradleVersion))
|
||||
|
||||
@@ -737,7 +744,6 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
arrayOf(
|
||||
it + "com/example/lib/CommonKt.class",
|
||||
it + "com/example/lib/MainKt.class",
|
||||
it + "Script.class",
|
||||
it + "META-INF/new-mpp-lib-with-tests.kotlin_module"
|
||||
)
|
||||
},
|
||||
@@ -751,22 +757,15 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
)
|
||||
|
||||
expectedKotlinOutputFiles.forEach { assertFileExists(it) }
|
||||
val expectedTestResults = projectDir.resolve("TEST-all.xml")
|
||||
|
||||
// Gradle 6.6+ slightly changed format of xml test results
|
||||
// If, in the test project, preset name was updated,
|
||||
// update accordingly test result output for Gradle 6.6+
|
||||
val testGradleVersion = chooseWrapperVersionOrFinishTest()
|
||||
val expectedTestResults = if (GradleVersion.version(testGradleVersion) < GradleVersion.version("6.6")) {
|
||||
"testProject/new-mpp-lib-with-tests/TEST-all-pre6.6.xml"
|
||||
} else {
|
||||
"testProject/new-mpp-lib-with-tests/TEST-all.xml"
|
||||
}
|
||||
expectedTestResults.replaceText("<target>", targetName)
|
||||
|
||||
assertTestResults(
|
||||
expectedTestResults,
|
||||
"jsNodeTest",
|
||||
"test", // jvmTest
|
||||
"${nativeHostTargetName}Test"
|
||||
"${targetName}Test"
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1796,7 +1795,11 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
gradleBuildScript().modify(::transformBuildScriptWithPluginsDsl)
|
||||
|
||||
// TOOD: add Kotlin/JS tests once they can be tested without much performance overhead
|
||||
val targetsToTest = listOf("jvm", nativeHostTargetName) + listOf("ios").takeIf { HostManager.hostIsMac }.orEmpty()
|
||||
val targetsToTest = listOf("jvm", nativeHostTargetName) + when (HostManager.host) {
|
||||
KonanTarget.MACOS_X64 -> listOf("iosX64")
|
||||
KonanTarget.MACOS_ARM64 -> listOf("iosSimulatorArm64")
|
||||
else -> emptyList()
|
||||
}
|
||||
val testTasks = targetsToTest.flatMap { listOf(":${it}Test", ":${it}IntegrationTest") }.toTypedArray()
|
||||
|
||||
build(*testTasks) {
|
||||
|
||||
+6
-5
@@ -30,11 +30,12 @@ import kotlin.test.assertFalse
|
||||
import kotlin.test.assertTrue
|
||||
|
||||
internal object MPPNativeTargets {
|
||||
val current = when {
|
||||
HostManager.hostIsMingw -> "mingw64"
|
||||
HostManager.hostIsLinux -> "linux64"
|
||||
HostManager.hostIsMac -> "macos64"
|
||||
else -> error("Unknown host")
|
||||
val current = when (HostManager.host) {
|
||||
KonanTarget.LINUX_X64 -> "linux64"
|
||||
KonanTarget.MACOS_X64 -> "macos64"
|
||||
KonanTarget.MACOS_ARM64 -> "macosArm64"
|
||||
KonanTarget.MINGW_X64 -> "mingw64"
|
||||
else -> error("Unsupported host")
|
||||
}
|
||||
|
||||
val unsupported = when {
|
||||
|
||||
+4
-2
@@ -49,7 +49,9 @@ kotlin {
|
||||
mingwX64("mingw64") {}
|
||||
linuxX64("linux64") {}
|
||||
macosX64("macos64") {}
|
||||
iosX64("ios") {}
|
||||
macosArm64("macosArm64") {}
|
||||
iosX64("iosX64") {}
|
||||
iosSimulatorArm64("iosSimulatorArm64") {}
|
||||
|
||||
targets.matching { it.name != "metadata" }.all {
|
||||
compilations.create("integrationTest") {
|
||||
@@ -90,7 +92,7 @@ kotlin {
|
||||
}
|
||||
}
|
||||
|
||||
targets.matching { it.name == "mingw64" || it.name == "linux64" || it.name == "macos64" || it.name == "ios" }.all {
|
||||
targets.matching { it.name == "mingw64" || it.name == "linux64" || it.name == "macos64" || it.name == "macosArm64" || it.name == "iosX64" || it.name == "iosSimulatorArm64" }.all {
|
||||
testRuns {
|
||||
getByName("test").filter { excludeTestsMatching("*.secondTest") }
|
||||
|
||||
|
||||
-43
@@ -1,43 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<results>
|
||||
<testsuite name="com.example.lib.TestCommonCode" tests="2" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="...">
|
||||
<properties />
|
||||
<testcase name="testId" classname="com.example.lib.TestCommonCode" time="..." />
|
||||
<testcase name="testExpectedFun" classname="com.example.lib.TestCommonCode" time="..." />
|
||||
<system-out />
|
||||
<system-err />
|
||||
</testsuite>
|
||||
<testsuite name="com.example.lib.TestCommonCode" tests="2" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="...">
|
||||
<properties />
|
||||
<testcase name="testId" classname="com.example.lib.TestCommonCode" time="..." />
|
||||
<testcase name="testExpectedFun" classname="com.example.lib.TestCommonCode" time="..." />
|
||||
<system-out><![CDATA[1]]></system-out>
|
||||
<system-err />
|
||||
</testsuite>
|
||||
<testsuite name="com.example.lib.TestCommonCode" tests="2" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="...">
|
||||
<properties />
|
||||
<testcase name="testId" classname="com.example.lib.TestCommonCode" time="..." />
|
||||
<testcase name="testExpectedFun" classname="com.example.lib.TestCommonCode" time="..." />
|
||||
<system-out />
|
||||
<system-err />
|
||||
</testsuite>
|
||||
<testsuite name="com.example.lib.TestJava" tests="1" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="...">
|
||||
<properties />
|
||||
<testcase name="testJava" classname="com.example.lib.TestJava" time="..." />
|
||||
<system-out />
|
||||
<system-err />
|
||||
</testsuite>
|
||||
<testsuite name="com.example.lib.TestJs" tests="1" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="...">
|
||||
<properties />
|
||||
<testcase name="testJsSpecificCode" classname="com.example.lib.TestJs" time="..." />
|
||||
<system-out />
|
||||
<system-err />
|
||||
</testsuite>
|
||||
<testsuite name="com.example.lib.TestWithJava" tests="1" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="...">
|
||||
<properties />
|
||||
<testcase name="testJavaClass" classname="com.example.lib.TestWithJava" time="..." />
|
||||
<system-out />
|
||||
<system-err />
|
||||
</testsuite>
|
||||
</results>
|
||||
|
||||
+2
-2
@@ -16,8 +16,8 @@
|
||||
</testsuite>
|
||||
<testsuite name="com.example.lib.TestCommonCode" tests="2" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="...">
|
||||
<properties />
|
||||
<testcase name="testId[linux64]" classname="com.example.lib.TestCommonCode" time="..." />
|
||||
<testcase name="testExpectedFun[linux64]" classname="com.example.lib.TestCommonCode" time="..." />
|
||||
<testcase name="testId[<target>]" classname="com.example.lib.TestCommonCode" time="..." />
|
||||
<testcase name="testExpectedFun[<target>]" classname="com.example.lib.TestCommonCode" time="..." />
|
||||
<system-out />
|
||||
<system-err />
|
||||
</testsuite>
|
||||
|
||||
+2
-1
@@ -23,6 +23,7 @@ kotlin {
|
||||
fromPreset(presets.jvm, 'jvmWithoutJava')
|
||||
fromPreset(presets.jvmWithJava, 'jvmWithJava')
|
||||
fromPreset(presets.macosX64, 'macos64')
|
||||
fromPreset(presets.macosArm64, 'macosArm64')
|
||||
fromPreset(presets.linuxX64, 'linux64')
|
||||
fromPreset(presets.mingwX64, 'mingw64')
|
||||
}
|
||||
@@ -56,7 +57,7 @@ kotlin {
|
||||
}
|
||||
}
|
||||
nativeMain
|
||||
configure([macos64Main, linux64Main, mingw64Main]) {
|
||||
configure([macos64Main, macosArm64Main, linux64Main, mingw64Main]) {
|
||||
dependsOn nativeMain
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -14,6 +14,7 @@ kotlin {
|
||||
nodejs()
|
||||
}
|
||||
val macos64 = macosX64("macos64")
|
||||
val macosArm64 = macosArm64("macosArm64")
|
||||
val linux64 = linuxX64("linux64")
|
||||
val mingw64 = mingwX64("mingw64")
|
||||
|
||||
@@ -49,7 +50,7 @@ kotlin {
|
||||
}
|
||||
|
||||
val nativeMain by creating
|
||||
configure(listOf(macos64, linux64, mingw64)) {
|
||||
configure(listOf(macos64, macosArm64, linux64, mingw64)) {
|
||||
compilations["main"].defaultSourceSet.dependsOn(nativeMain)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user