[Gradle][test] Correct iOS simulator targets for both x64 and arm64

This commit is contained in:
Pavel Punegov
2022-01-31 14:16:35 +03:00
committed by Space
parent 219d5e3ecf
commit a8f2e9ced7
2 changed files with 24 additions and 20 deletions
@@ -17,7 +17,6 @@ import org.jetbrains.kotlin.gradle.internals.NO_NATIVE_STDLIB_PROPERTY_WARNING
import org.jetbrains.kotlin.gradle.internals.NO_NATIVE_STDLIB_WARNING import org.jetbrains.kotlin.gradle.internals.NO_NATIVE_STDLIB_WARNING
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeOutputKind import org.jetbrains.kotlin.gradle.plugin.mpp.NativeOutputKind
import org.jetbrains.kotlin.gradle.transformProjectWithPluginsDsl import org.jetbrains.kotlin.gradle.transformProjectWithPluginsDsl
import org.jetbrains.kotlin.gradle.util.isWindows
import org.jetbrains.kotlin.gradle.util.modify import org.jetbrains.kotlin.gradle.util.modify
import org.jetbrains.kotlin.gradle.util.runProcess import org.jetbrains.kotlin.gradle.util.runProcess
import org.jetbrains.kotlin.konan.target.CompilerOutputKind import org.jetbrains.kotlin.konan.target.CompilerOutputKind
@@ -596,11 +595,18 @@ class GeneralNativeIT : BaseGradleIT() {
@Test @Test
fun testNativeTests() = with(transformNativeTestProject("native-tests")) { fun testNativeTests() = with(transformNativeTestProject("native-tests")) {
val testTasks = listOf("hostTest", "iosTest")
val hostTestTask = "hostTest" val hostTestTask = "hostTest"
val testTasks = listOf(hostTestTask, "iosTest", "iosArm64Test")
val suffix = if (isWindows) "exe" else "kexe" val testsToExecute = mutableListOf(":$hostTestTask")
when (HostManager.host) {
KonanTarget.MACOS_X64 -> testsToExecute.add(":iosTest")
KonanTarget.MACOS_ARM64 -> testsToExecute.add(":iosArm64Test")
else -> {}
}
val testsToSkip = testTasks.map { ":$it" } - testsToExecute
val suffix = HostManager.host.family.exeSuffix
val defaultOutputFile = "build/bin/host/debugTest/test.$suffix" val defaultOutputFile = "build/bin/host/debugTest/test.$suffix"
val anotherOutputFile = "build/bin/host/anotherDebugTest/another.$suffix" val anotherOutputFile = "build/bin/host/anotherDebugTest/another.$suffix"
@@ -620,14 +626,6 @@ class GeneralNativeIT : BaseGradleIT() {
assertNoSuchFile(anotherOutputFile) assertNoSuchFile(anotherOutputFile)
} }
val testsToExecute = mutableListOf(":$hostTestTask")
when (HostManager.host) {
KonanTarget.MACOS_X64 -> testsToExecute.add(":iosTest")
KonanTarget.MACOS_ARM64 -> testsToExecute.add(":iosArm64Test")
else -> { }
}
val testsToSkip = testTasks.map { ":$it" } - testsToExecute
// Store currently booted simulators to check that they don't leak (MacOS only). // Store currently booted simulators to check that they don't leak (MacOS only).
val bootedSimulatorsBefore = getBootedSimulators(projectDir) val bootedSimulatorsBefore = getBootedSimulators(projectDir)
@@ -753,21 +751,27 @@ class GeneralNativeIT : BaseGradleIT() {
expectedHostTestResult = "testProject/native-tests/TEST-TestKt.xml" expectedHostTestResult = "testProject/native-tests/TEST-TestKt.xml"
expectedIOSTestResults = listOf( expectedIOSTestResults = listOf(
"testProject/native-tests/TEST-TestKt-iOSsim.xml", "testProject/native-tests/TEST-TestKt-iOSsim.xml",
"testProject/native-tests/TEST-TestKt-iOSsim_wWarn.xml", "testProject/native-tests/TEST-TestKt-iOSArm64sim.xml",
) )
} }
assertTestResults(expectedHostTestResult, hostTestTask) assertTestResults(expectedHostTestResult, hostTestTask)
// K/N doesn't report line numbers correctly on Linux (see KT-35408). // K/N doesn't report line numbers correctly on Linux (see KT-35408).
// TODO: Uncomment when this is fixed. // TODO: Move assertStacktrace(hostTestTask, "host") out of if clause
//assertStacktrace(hostTestTask, "host")
if (HostManager.hostIsMac) { if (HostManager.hostIsMac) {
assertStacktrace(hostTestTask, "host")
val testTarget = when (HostManager.host) {
KonanTarget.MACOS_ARM64 -> "iosArm64"
KonanTarget.MACOS_X64 -> "ios"
else -> throw IllegalStateException("Unsupported host: ${HostManager.host}")
}
val testTask = "${testTarget}Test"
assertTestResultsAnyOf( assertTestResultsAnyOf(
expectedIOSTestResults[0], expectedIOSTestResults[0],
expectedIOSTestResults[1], expectedIOSTestResults[1],
"iosTest" testTask
) )
assertStacktrace("iosTest", "ios") assertStacktrace(testTask, testTarget)
} }
} }
} }
@@ -2,10 +2,10 @@
<results> <results>
<testsuite name="org.foo.test.TestKt" tests="4" skipped="0" failures="1" errors="0" timestamp="..." hostname="..." time="..."> <testsuite name="org.foo.test.TestKt" tests="4" skipped="0" failures="1" errors="0" timestamp="..." hostname="..." time="...">
<properties/> <properties/>
<testcase name="fooTest[ios]" classname="org.foo.test.TestKt" time="..."/> <testcase name="fooTest[iosArm64]" classname="org.foo.test.TestKt" time="..."/>
<testcase name="barTest[ios]" classname="org.foo.test.TestKt" time="..."/> <testcase name="barTest[iosArm64]" classname="org.foo.test.TestKt" time="..."/>
<testcase name="barfooTest[ios]" classname="org.foo.test.TestKt" time="..."/> <testcase name="barfooTest[iosArm64]" classname="org.foo.test.TestKt" time="..."/>
<testcase name="fail[ios]" classname="org.foo.test.TestKt" time="..."> <testcase name="fail[iosArm64]" classname="org.foo.test.TestKt" time="...">
<failure message="..." type="kotlin.IllegalStateException">...</failure> <failure message="..." type="kotlin.IllegalStateException">...</failure>
</testcase> </testcase>
<system-out><![CDATA[Foo call <system-out><![CDATA[Foo call