diff --git a/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/devicerun/DeviceRunController.kt b/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/devicerun/DeviceRunController.kt index 14dc672..8ed5683 100644 --- a/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/devicerun/DeviceRunController.kt +++ b/AndroidXCI/lib/src/main/kotlin/dev/androidx/ci/devicerun/DeviceRunController.kt @@ -171,16 +171,16 @@ internal class DeviceRunController( } // Move AndroidJUnitRunner filter keys (package, class, annotation, etc.) from extraOptions to testTargets if necessary. val filterKeys = listOf("package", "notPackage", "class", "notClass", "annotation", "notAnnotation", "size") - val filteredOptions = extraOptions.filter { opt -> - val key = opt.substringBefore('=') + val filteredOptions = mutableMapOf() + extraOptions.forEach { opt -> + val key = opt.substringBefore('=').trim() + val value = opt.substringAfter('=').trim() if (filterKeys.contains(key)) { - val value = opt.substringAfter('=') - value.split(',').forEach { v -> + value.split(',').map { it.trim() }.filter { it.isNotEmpty() }.forEach { v -> mappedTestTargets.add("$key $v") } - false } else { - true + filteredOptions[key] = value } } diff --git a/AndroidXCI/lib/src/test/kotlin/dev/androidx/ci/devicerun/DeviceRunControllerTest.kt b/AndroidXCI/lib/src/test/kotlin/dev/androidx/ci/devicerun/DeviceRunControllerTest.kt index 6f03183..c4db2c4 100644 --- a/AndroidXCI/lib/src/test/kotlin/dev/androidx/ci/devicerun/DeviceRunControllerTest.kt +++ b/AndroidXCI/lib/src/test/kotlin/dev/androidx/ci/devicerun/DeviceRunControllerTest.kt @@ -141,11 +141,11 @@ internal class DeviceRunControllerTest { assertThat(testTargets.size).isEqualTo(3) // Verify non-filter keys remained in extra options along with implicit defaults - val additionalTestOptions = instrumentationTest?.additionalTestOptions ?: emptyList() - val optionsSet = additionalTestOptions as List<*> - assertThat(optionsSet.contains("disable_window_animations=true")).isTrue() - assertThat(optionsSet.contains("firebase.test.lab=true")).isTrue() - assertThat(optionsSet.contains("customKey=customValue")).isTrue() + @Suppress("UNCHECKED_CAST") + val additionalTestOptions = instrumentationTest?.additionalTestOptions as? Map ?: emptyMap() + assertThat(additionalTestOptions["disable_window_animations"]).isEqualTo("true") + assertThat(additionalTestOptions["firebase.test.lab"]).isEqualTo("true") + assertThat(additionalTestOptions["customKey"]).isEqualTo("customValue") assertThat(additionalTestOptions.size).isEqualTo(3) }