Skip to content

Commit 3daebd8

Browse files
fix: Detect iOS devices as physical (#2182)
* fix: Detect iOS devices as physical * Try to fix ios exception * Update BillableMinutesTest.kt * Update BillableMinutesTest.kt * Fix IosArgsTest * Add GitHub rate limit work around
1 parent c028595 commit 3daebd8

6 files changed

Lines changed: 30 additions & 27 deletions

File tree

build.gradle.kts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
32
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
43
import org.jmailen.gradle.kotlinter.tasks.LintTask
@@ -86,10 +85,16 @@ val resolveArtifacts by tasks.registering {
8685
"flankScripts.bat" else "flankScripts"
8786
val flankScriptsPath = Paths.get("flank-scripts", "bash", flankScriptsRunnerName).toString()
8887
val rootFlankScriptsPath = rootDir.resolve(flankScriptsPath).absolutePath
89-
println(rootFlankScriptsPath)
90-
exec {
91-
commandLine(rootFlankScriptsPath, "testArtifacts", "-p", rootDir.absolutePath, "resolve")
92-
workingDir = rootDir
88+
try {
89+
exec {
90+
val cmd = listOf(rootFlankScriptsPath, "testArtifacts", "-p", rootDir.absolutePath, "resolve")
91+
println(cmd.joinToString(" "))
92+
commandLine(cmd)
93+
workingDir = rootDir
94+
}
95+
} catch (e: Exception) {
96+
// avoid breaking all gradle builds if github has rate limited us by not throwing the exception
97+
e.printStackTrace()
9398
}
9499
}
95100
}

test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ private fun IosArgs.assertXcodeSupported() = when {
8484

8585
private fun IosArgs.assertDevicesSupported() = devices.forEach { device ->
8686
if (!isDeviceSupported(device.model, device.version, this.project))
87-
throw IncompatibleTestDimensionError("iOS ${device.version} on ${device.model} is not a supported\nSupported version ids for '${device.model}': ${device.getSupportedVersionId(project).joinToString()}")
87+
throw IncompatibleTestDimensionError("iOS ${device.version} on ${device.model} is not supported\nSupported version ids for '${device.model}': ${device.getSupportedVersionId(project).joinToString()}")
8888
}
8989

9090
@VisibleForTesting

test_runner/src/main/kotlin/ftl/client/google/AndroidCatalog.kt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ object AndroidCatalog {
1717
private val modelMap: MutableMap<String, List<String>> = mutableMapOf()
1818
private val versionMap: MutableMap<String, List<String>> = mutableMapOf()
1919

20-
private fun deviceCatalog(projectId: String) = catalogMap.getOrPut(projectId) {
20+
private fun androidDeviceCatalog(projectId: String) = catalogMap.getOrPut(projectId) {
2121
GcTesting.get.testEnvironmentCatalog()
2222
.get("android")
2323
.setProjectId(projectId)
@@ -29,26 +29,29 @@ object AndroidCatalog {
2929
private fun AndroidDeviceCatalog.filterDevicesWithoutSupportedVersions() =
3030
setModels(models.filterNotNull().filter { it.supportedVersionIds?.isNotEmpty() ?: false })
3131

32-
fun getModels(projectId: String): List<AndroidModel> = deviceCatalog(projectId).models.orEmpty()
32+
fun getModels(projectId: String): List<AndroidModel> = androidDeviceCatalog(projectId).models.orEmpty()
3333

3434
fun supportedOrientations(projectId: String): List<Orientation> =
35-
deviceCatalog(projectId).runtimeConfiguration.orientations
35+
androidDeviceCatalog(projectId).runtimeConfiguration.orientations
3636

37-
internal fun getLocales(projectId: String) = deviceCatalog(projectId).runtimeConfiguration.locales
37+
internal fun getLocales(projectId: String) = androidDeviceCatalog(projectId).runtimeConfiguration.locales
3838

3939
fun androidModelIds(projectId: String) =
40-
modelMap.getOrPut(projectId) { deviceCatalog(projectId).models.map { it.id } }
40+
modelMap.getOrPut(projectId) { androidDeviceCatalog(projectId).models.map { it.id } }
4141

4242
fun androidVersionIds(projectId: String) =
43-
versionMap.getOrPut(projectId) { deviceCatalog(projectId).versions.map { it.id } }
43+
versionMap.getOrPut(projectId) { androidDeviceCatalog(projectId).versions.map { it.id } }
4444

4545
fun isVirtualDevice(device: AndroidDevice?, projectId: String): Boolean = device
4646
?.androidModelId
4747
?.let { isVirtualDevice(it, projectId) }
4848
?: false
4949

5050
fun isVirtualDevice(modelId: String, projectId: String): Boolean {
51-
val form = deviceCatalog(projectId).models
51+
val isIos = IosCatalog.getModels(projectId).any { it.id.equals(modelId, ignoreCase = true) }
52+
if (isIos) return false
53+
54+
val form = androidDeviceCatalog(projectId).models
5255
.find { it.id.equals(modelId, ignoreCase = true) }?.form
5356
?: DeviceType.PHYSICAL.name.also {
5457
ReportManagerState.Log(

test_runner/src/main/kotlin/ftl/client/google/IosCatalog.kt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -55,19 +55,7 @@ object IosCatalog {
5555
.filterDevicesWithoutSupportedVersions()
5656
}
5757
} catch (e: java.lang.Exception) {
58-
throw java.lang.RuntimeException(
59-
"""
60-
Unable to access the test environment catalogMap. Firebase Test Lab for iOS is currently in beta.
61-
Request access for your project via the following form:
62-
https://goo.gl/forms/wAxbiNEP2pxeIRG82
63-
64-
If this project has already been granted access, please make sure you are using a project
65-
on the Blaze or Flame billing plans, and that you have run
66-
gcloud config set billing/quota_project project
67-
68-
If you are still having issues, please email ftl-ios-feedback@google.com for support.""",
69-
e
70-
)
58+
throw java.lang.RuntimeException(e)
7159
}
7260

7361
private fun IosDeviceCatalog.filterDevicesWithoutSupportedVersions() =

test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ flank:
137137

138138
@Test
139139
fun `args invalidDeviceExits`() {
140-
assertThrowsWithMessage(Throwable::class, "iOS 11.2 on iphonexsmax is not a supported\nSupported version ids for 'iphonexsmax': 12.1, 12.3") {
140+
assertThrowsWithMessage(Throwable::class, "iOS 11.2 on iphonexsmax is not supported\nSupported version ids for 'iphonexsmax': 12.1") {
141141
val invalidDevice = mutableListOf(Device("iphonexsmax", "11.2"))
142142
createIosArgs(
143143
config = defaultIosConfig().apply {

test_runner/src/test/kotlin/ftl/reports/outcome/BillableMinutesTest.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package ftl.reports.outcome
22

33
import com.google.api.services.toolresults.model.Step
44
import com.google.testing.model.AndroidModel
5+
import com.google.testing.model.IosModel
56
import ftl.client.google.BillableMinutes
67
import ftl.client.google.DeviceType
78
import ftl.client.google.GcTesting
@@ -31,6 +32,11 @@ class BillableMinutesTest {
3132
make { id = "nullVersions"; form = DeviceType.PHYSICAL.name; supportedVersionIds = null }
3233
)
3334

35+
private val iosModels = listOf<IosModel>(
36+
make { id = "iphone11"; supportedVersionIds = listOf("13.3", "13.6") },
37+
make { id = "ipad5"; supportedVersionIds = listOf("14.1") }
38+
)
39+
3440
@Before
3541
fun setUp() {
3642
output.clearLog()
@@ -44,6 +50,7 @@ class BillableMinutesTest {
4450
.executeWithRetry()
4551
} returns make {
4652
androidDeviceCatalog = make { models = androidModels }
53+
iosDeviceCatalog = make { models = iosModels }
4754
}
4855
}
4956

0 commit comments

Comments
 (0)