Skip to content

Commit

Permalink
Fix mempool.space ios tests
Browse files Browse the repository at this point in the history
These tests include https calls which won't work the ios simulator is started in standalone mode, which is the default option.
  • Loading branch information
sstone committed Mar 26, 2024
1 parent eba5a5b commit f513c21
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeTest
import java.io.ByteArrayOutputStream

plugins {
kotlin("multiplatform") version "1.9.23"
Expand Down Expand Up @@ -265,6 +266,33 @@ afterEvaluate {
}))
}
}

val deviceName = project.findProperty("iosDevice") as? String ?: "iPhone 15"

val startIosSimulator by tasks.creating(Exec::class) {
isIgnoreExitValue = true
errorOutput = ByteArrayOutputStream()
commandLine("xcrun", "simctl", "boot", deviceName)
doLast {
val result = executionResult.get()
if (result.exitValue != 148 && result.exitValue != 149) {
println(errorOutput.toString())
result.assertNormalExitValue()
}
}
}

val stopIosSimulator by tasks.creating(Exec::class) {
commandLine("xcrun", "simctl", "shutdown", "all")
}

tasks.withType<org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeSimulatorTest>().configureEach {
dependsOn(startIosSimulator)
device = deviceName
standalone.set(false)
finalizedBy(stopIosSimulator)
}

tasks.withType<org.jetbrains.kotlin.gradle.targets.jvm.tasks.KotlinJvmTest> {
environment("TEST_RESOURCES_PATH", projectDir.resolve("src/commonTest/resources"))
}
Expand Down Expand Up @@ -303,7 +331,7 @@ tasks.withType<AbstractTestTask> {
// Those tests use TLS sockets which are not supported on Linux and MacOS
tasks
.filterIsInstance<KotlinNativeTest>()
.filter { it.name == "macosX64Test" || it.name == "linuxX64Test" }
.filter { it.name == "macosX64Test" || it.name == "macosArm64Test" || it.name == "linuxX64Test" }
.map {
it.filter.excludeTestsMatching("*IntegrationTest")
it.filter.excludeTestsMatching("*ElectrumClientTest")
Expand Down

0 comments on commit f513c21

Please sign in to comment.