diff --git a/vendor/vendor-apple/base/src/main/kotlin/com/malinskiy/marathon/apple/logparser/parser/DeviceFailureException.kt b/vendor/vendor-apple/base/src/main/kotlin/com/malinskiy/marathon/apple/logparser/parser/DeviceFailureException.kt index 89aa65143..5fb4c54e3 100644 --- a/vendor/vendor-apple/base/src/main/kotlin/com/malinskiy/marathon/apple/logparser/parser/DeviceFailureException.kt +++ b/vendor/vendor-apple/base/src/main/kotlin/com/malinskiy/marathon/apple/logparser/parser/DeviceFailureException.kt @@ -1,6 +1,6 @@ package com.malinskiy.marathon.apple.logparser.parser -enum class DeviceFailureReason { Unknown, FailedRunner, ConnectionAbort, InvalidSimulatorIdentifier, UnreachableHost, ServicesUnavailable } +enum class DeviceFailureReason { Unknown, FailedRunner, ConnectionAbort, InvalidSimulatorIdentifier, UnreachableHost, ServicesUnavailable, IncompatibleDevice } class DeviceFailureException( val reason: DeviceFailureReason, diff --git a/vendor/vendor-apple/base/src/main/kotlin/com/malinskiy/marathon/apple/plist/bundle/BundleInfo.kt b/vendor/vendor-apple/base/src/main/kotlin/com/malinskiy/marathon/apple/plist/bundle/BundleInfo.kt index 94cd4301f..993eac47b 100644 --- a/vendor/vendor-apple/base/src/main/kotlin/com/malinskiy/marathon/apple/plist/bundle/BundleInfo.kt +++ b/vendor/vendor-apple/base/src/main/kotlin/com/malinskiy/marathon/apple/plist/bundle/BundleInfo.kt @@ -7,4 +7,5 @@ class BundleInfo(delegate: NSDictionary) : PropertyList(delegate) val categorization = Categorization(delegate) val identification = Identification(delegate) val naming = Naming(delegate) + val undocumented = Undocumented(delegate) } diff --git a/vendor/vendor-apple/base/src/main/kotlin/com/malinskiy/marathon/apple/xctestrun/TestRootFactory.kt b/vendor/vendor-apple/base/src/main/kotlin/com/malinskiy/marathon/apple/xctestrun/TestRootFactory.kt index 0df20365b..bb9145ea0 100644 --- a/vendor/vendor-apple/base/src/main/kotlin/com/malinskiy/marathon/apple/xctestrun/TestRootFactory.kt +++ b/vendor/vendor-apple/base/src/main/kotlin/com/malinskiy/marathon/apple/xctestrun/TestRootFactory.kt @@ -2,15 +2,19 @@ package com.malinskiy.marathon.apple.xctestrun import com.malinskiy.marathon.apple.AppleDevice import com.malinskiy.marathon.apple.RemoteFileManager +import com.malinskiy.marathon.apple.logparser.parser.DeviceFailureException +import com.malinskiy.marathon.apple.logparser.parser.DeviceFailureReason import com.malinskiy.marathon.apple.model.AppleTestBundle import com.malinskiy.marathon.apple.model.Arch import com.malinskiy.marathon.apple.model.Sdk +import com.malinskiy.marathon.apple.plist.bundle.BundleInfo import com.malinskiy.marathon.apple.xctestrun.v2.TestConfiguration import com.malinskiy.marathon.apple.xctestrun.v2.TestTarget import com.malinskiy.marathon.apple.xctestrun.v2.Xctestrun import com.malinskiy.marathon.config.exceptions.ConfigurationException import com.malinskiy.marathon.config.vendor.apple.TestType import com.malinskiy.marathon.config.vendor.apple.ios.XcresultConfiguration +import com.malinskiy.marathon.exceptions.DeviceLostException import com.malinskiy.marathon.exceptions.DeviceSetupException import com.malinskiy.marathon.exceptions.TransferException import java.io.File @@ -28,6 +32,8 @@ class TestRootFactory( val testRoot = remoteFileManager.remoteTestRoot() remoteFileManager.createRemoteDirectory(testRoot) + validateDeviceCompatibility(device, bundle) + val xctestrun = when (testType) { TestType.XCUITEST -> generateXCUITest(testRoot, remoteFileManager, bundle, useXctestParser) TestType.XCTEST -> generateXCTest(testRoot, remoteFileManager, bundle, useXctestParser) @@ -46,6 +52,29 @@ class TestRootFactory( } } + private fun validateDeviceCompatibility(device: AppleDevice, bundle: AppleTestBundle) { + bundle.applicationBundleInfo?.let { validateDeviceBundle(it, device) } + validateDeviceBundle(bundle.testBundleInfo, device) + } + + private fun validateDeviceBundle(bundle: BundleInfo, device: AppleDevice) { + val bundleSupportedPlatforms = bundle.undocumented.bundleSupportedPlatforms + val platform = device.sdk.platformName + if (!bundleSupportedPlatforms.contains(platform)) { + throw DeviceLostException( + DeviceFailureException( + reason = DeviceFailureReason.IncompatibleDevice, + message = "Device ${device.serialNumber} with platform $platform " + + "is incompatible with bundle's supported platforms [${ + bundleSupportedPlatforms.joinToString( + "," + ) + }]" + ) + ) + } + } + private suspend fun generateXCUITest( testRoot: String, remoteFileManager: RemoteFileManager,