|
5 | 5 | import aws.sdk.kotlin.gradle.dsl.configurePublishing |
6 | 6 | import aws.sdk.kotlin.gradle.kmp.* |
7 | 7 | import aws.sdk.kotlin.gradle.util.typedProp |
| 8 | +import org.gradle.kotlin.dsl.withType |
8 | 9 | import org.jetbrains.kotlin.gradle.dsl.JvmTarget |
| 10 | +import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest |
| 11 | +import org.jetbrains.kotlin.konan.target.HostManager |
9 | 12 |
|
10 | 13 | plugins { |
11 | 14 | alias(libs.plugins.dokka) |
@@ -67,6 +70,47 @@ subprojects { |
67 | 70 | } |
68 | 71 | } |
69 | 72 | } |
| 73 | + |
| 74 | + |
| 75 | + // disable "standalone" mode in simulator tests since it causes TLS issues. this means we need to manage the simulator |
| 76 | + // ourselves (booting / shutting down). FIXME: https://youtrack.jetbrains.com/issue/KT-38317 |
| 77 | + val simulatorDeviceName = project.findProperty("iosSimulatorDevice") as? String ?: "iPhone 15" |
| 78 | + |
| 79 | + val xcrun = "/usr/bin/xcrun" |
| 80 | + |
| 81 | + tasks.register<Exec>("bootIosSimulatorDevice") { |
| 82 | + isIgnoreExitValue = true |
| 83 | + commandLine(xcrun, "simctl", "boot", simulatorDeviceName) |
| 84 | + |
| 85 | + doLast { |
| 86 | + val result = executionResult.get() |
| 87 | + val code = result.exitValue |
| 88 | + if (code != 148 && code != 149) { // ignore "simulator already running" errors |
| 89 | + result.assertNormalExitValue() |
| 90 | + } |
| 91 | + } |
| 92 | + } |
| 93 | + |
| 94 | + tasks.register<Exec>("shutdownIosSimulatorDevice") { |
| 95 | + mustRunAfter(tasks.withType<KotlinNativeSimulatorTest>()) |
| 96 | + commandLine(xcrun, "simctl", "shutdown", simulatorDeviceName) |
| 97 | + |
| 98 | + doLast { |
| 99 | + executionResult.get().assertNormalExitValue() |
| 100 | + } |
| 101 | + } |
| 102 | + |
| 103 | + tasks.withType<KotlinNativeSimulatorTest>().configureEach { |
| 104 | + if (!HostManager.hostIsMac) { |
| 105 | + return@configureEach |
| 106 | + } |
| 107 | + |
| 108 | + dependsOn("bootIosSimulatorDevice") |
| 109 | + finalizedBy("shutdownIosSimulatorDevice") |
| 110 | + |
| 111 | + standalone = false |
| 112 | + device = simulatorDeviceName |
| 113 | + } |
70 | 114 | } |
71 | 115 |
|
72 | 116 | kotlin.sourceSets.all { |
|
0 commit comments