[K/N][test] Synchronized simulator device check
Test infrastructure runs tests in parallel for the same target executor. Device descriptor should be synchronously checked and set. Also fix the Xcode version comparison. Merge-request: KT-MR-14256 Merged-by: Pavel Punegov <Pavel.Punegov@jetbrains.com>
This commit is contained in:
committed by
Space Team
parent
1f30d076de
commit
fb3bd1c3ef
+6
-2
@@ -10,6 +10,8 @@ import org.jetbrains.kotlin.*
|
|||||||
import java.io.ByteArrayOutputStream
|
import java.io.ByteArrayOutputStream
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.logging.Logger
|
import java.util.logging.Logger
|
||||||
|
import kotlin.jvm.Volatile
|
||||||
|
import kotlin.jvm.Synchronized
|
||||||
|
|
||||||
private fun defaultDeviceId(target: KonanTarget) = when (target.family) {
|
private fun defaultDeviceId(target: KonanTarget) = when (target.family) {
|
||||||
Family.TVOS -> "com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-4K"
|
Family.TVOS -> "com.apple.CoreSimulator.SimDeviceType.Apple-TV-4K-4K"
|
||||||
@@ -61,15 +63,17 @@ class XcodeSimulatorExecutor(
|
|||||||
return hostExecutor.runProcess("/usr/bin/xcrun", "simctl", *args).stdout
|
return hostExecutor.runProcess("/usr/bin/xcrun", "simctl", *args).stdout
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Volatile
|
||||||
private var deviceChecked: SimulatorDeviceDescriptor? = null
|
private var deviceChecked: SimulatorDeviceDescriptor? = null
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
private fun ensureSimulatorExists() {
|
private fun ensureSimulatorExists() {
|
||||||
// Already ensured that simulator for `deviceId` exists.
|
// Already ensured that simulator for `deviceId` exists.
|
||||||
if (deviceId == deviceChecked?.deviceTypeIdentifier) {
|
if (deviceId == deviceChecked?.deviceTypeIdentifier) {
|
||||||
logger.info("Device already exists: ${deviceChecked?.deviceTypeIdentifier} with name ${deviceChecked?.name}")
|
logger.info("Device already exists: ${deviceChecked?.deviceTypeIdentifier} with name ${deviceChecked?.name}")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
logger.info("Device was not cheked before. Find the device with id: $deviceId")
|
logger.info("Device was not checked before. Find the device with id: $deviceId")
|
||||||
val simulatorRuntime = getSimulatorRuntime()
|
val simulatorRuntime = getSimulatorRuntime()
|
||||||
logger.info("Runtime used for the $deviceId is $simulatorRuntime")
|
logger.info("Runtime used for the $deviceId is $simulatorRuntime")
|
||||||
|
|
||||||
@@ -136,7 +140,7 @@ class XcodeSimulatorExecutor(
|
|||||||
check(version.major >= 14) {
|
check(version.major >= 14) {
|
||||||
"Was unable to get the required runtimes running on Xcode $version. Check the Xcode installation"
|
"Was unable to get the required runtimes running on Xcode $version. Check the Xcode installation"
|
||||||
}
|
}
|
||||||
if (version.minor >= 1) {
|
if (version >= XcodeVersion(14, 1)) {
|
||||||
// Option -downloadPlatform NAME available only since 14.1
|
// Option -downloadPlatform NAME available only since 14.1
|
||||||
hostExecutor.runProcess("/usr/bin/xcrun", "xcodebuild", "-downloadPlatform", osName)
|
hostExecutor.runProcess("/usr/bin/xcrun", "xcodebuild", "-downloadPlatform", osName)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user