From cc005115fd9b24be3d2a47e8c98e0e9e65c65fc5 Mon Sep 17 00:00:00 2001 From: sstone Date: Tue, 26 Mar 2024 15:13:07 +0100 Subject: [PATCH] Fix mempool.space ios tests These tests include https calls which won't work if the ios simulator is started in standalone mode, which is the default mode. --- build.gradle.kts | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 619f1b781..b4104bfa4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -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" @@ -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().configureEach { + dependsOn(startIosSimulator) + device = deviceName + standalone.set(false) + finalizedBy(stopIosSimulator) + } + tasks.withType { environment("TEST_RESOURCES_PATH", projectDir.resolve("src/commonTest/resources")) } @@ -303,7 +331,7 @@ tasks.withType { // Those tests use TLS sockets which are not supported on Linux and MacOS tasks .filterIsInstance() - .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")