diff --git a/test_runner/src/main/kotlin/ftl/client/google/run/Utils.kt b/test_runner/src/main/kotlin/ftl/client/google/run/Utils.kt index 0684326337..5c538528ef 100644 --- a/test_runner/src/main/kotlin/ftl/client/google/run/Utils.kt +++ b/test_runner/src/main/kotlin/ftl/client/google/run/Utils.kt @@ -3,12 +3,15 @@ package ftl.client.google.run import com.google.testing.model.ClientInfoDetail import com.google.testing.model.FileReference import com.google.testing.model.IosDeviceFile +import ftl.util.readRevision +import ftl.util.readVersion internal fun List.mapGcsPathsToFileReference(): List = map { it.toFileReference() } fun String.toFileReference(): FileReference = FileReference().setGcsPath(this) -internal fun Map.mapToIosDeviceFiles(): List = map { (testDevicePath, gcsFilePath) -> toIosDeviceFile(testDevicePath, gcsFilePath) } +internal fun Map.mapToIosDeviceFiles(): List = + map { (testDevicePath, gcsFilePath) -> toIosDeviceFile(testDevicePath, gcsFilePath) } internal fun toIosDeviceFile(testDevicePath: String, gcsFilePath: String = "") = IosDeviceFile().apply { if (testDevicePath.contains(":")) { @@ -21,8 +24,19 @@ internal fun toIosDeviceFile(testDevicePath: String, gcsFilePath: String = "") = content = FileReference().setGcsPath(gcsFilePath) } -internal fun Map.toClientInfoDetailList() = map { (key, value) -> +internal fun Map?.toClientInfoDetailList() = + (this ?: emptyMap()).map { (key, value) -> + ClientInfoDetail() + .setKey(key) + .setValue(value) + }.addFlankVersionInfo() + +private fun List.addFlankVersionInfo() = plus( ClientInfoDetail() - .setKey(key) - .setValue(value) -} + .setKey("Flank Version") + .setValue(readVersion()) +).plus( + ClientInfoDetail() + .setKey("Flank Revision") + .setValue(readRevision()) +) diff --git a/test_runner/src/main/kotlin/ftl/client/google/run/android/GcAndroidTestMatrix.kt b/test_runner/src/main/kotlin/ftl/client/google/run/android/GcAndroidTestMatrix.kt index fd74282151..6765240e1a 100644 --- a/test_runner/src/main/kotlin/ftl/client/google/run/android/GcAndroidTestMatrix.kt +++ b/test_runner/src/main/kotlin/ftl/client/google/run/android/GcAndroidTestMatrix.kt @@ -74,7 +74,7 @@ private fun createAndroidTestMatrix( private val TestMatrixAndroid.Config.clientInfo get() = ClientInfo() .setName("Flank") - .setClientInfoDetails(clientDetails?.toClientInfoDetailList()) + .setClientInfoDetails(clientDetails.toClientInfoDetailList()) private val TestMatrixAndroid.Config.environmentMatrix get() = EnvironmentMatrix() diff --git a/test_runner/src/main/kotlin/ftl/client/google/run/ios/GcIosTestMatrix.kt b/test_runner/src/main/kotlin/ftl/client/google/run/ios/GcIosTestMatrix.kt index d7c0151c40..6daf51eca4 100644 --- a/test_runner/src/main/kotlin/ftl/client/google/run/ios/GcIosTestMatrix.kt +++ b/test_runner/src/main/kotlin/ftl/client/google/run/ios/GcIosTestMatrix.kt @@ -90,4 +90,4 @@ private fun getIosTestSetup( private fun List.toIosDeviceFiles() = map { path -> toIosDeviceFile(path) } private val TestMatrixIos.Config.clientInfo - get() = ClientInfo().setName("Flank").setClientInfoDetails(clientDetails?.toClientInfoDetailList()) + get() = ClientInfo().setName("Flank").setClientInfoDetails(clientDetails.toClientInfoDetailList()) diff --git a/test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt b/test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt index 4a6a24ef6d..5edeeee2cc 100644 --- a/test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt +++ b/test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt @@ -1388,18 +1388,18 @@ AndroidArgs matrixMap.map .toList().apply { // test the module which overrides and adds client details - first { it.second.clientDetails!!.size == 3 } + first { it.second.clientDetails!!.size == 5 } .apply { assertEquals("val1", second.clientDetails!!["key1"]) assertEquals("val2", second.clientDetails!!["key2"]) assertEquals("overwritten-top-val1", second.clientDetails!!["top-key1"]) } // test all other modules got top level client details - first { it.second.clientDetails!!.size == 1 } + first { it.second.clientDetails!!.size == 3 } .apply { assertEquals("top-val1", second.clientDetails!!["top-key1"]) } - last { it.second.clientDetails!!.size == 1 } + last { it.second.clientDetails!!.size == 3 } .apply { assertEquals("top-val1", second.clientDetails!!["top-key1"]) } @@ -1408,6 +1408,28 @@ AndroidArgs assertEquals(3, chunks.size) } + @Test + fun `should add flank version to client-details even if client-details is empty`() { + val yaml = """ + gcloud: + app: $appApk + test: $testApk + flank: + additional-app-test-apks: + - test: $testErrorApk + - app: null + test: $testErrorApk + """.trimIndent() + + val parsedYml = AndroidArgs.load(yaml).validate() + + val (matrixMap) = runBlocking { parsedYml.runAndroidTests() } + assertTrue( + "Not all matrices have the `Flank Version` client-detail", + matrixMap.map.all { it.value.clientDetails!!.containsKey("Flank Version") && it.value.clientDetails!!.containsKey("Flank Revision") } + ) + } + @Test fun `cli keep-file-path`() { val cli = AndroidRunCommand() diff --git a/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt b/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt index 3555ac81ea..a437b150cb 100644 --- a/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt +++ b/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt @@ -10,6 +10,7 @@ import ftl.config.defaultIosConfig import ftl.ios.xctest.flattenShardChunks import ftl.presentation.cli.firebase.test.ios.IosRunCommand import ftl.run.exception.FlankConfigurationError +import ftl.run.platform.runIosTests import ftl.run.status.OutputStyle import ftl.test.util.FlankTestRunner import ftl.test.util.TestHelper.absolutePath @@ -18,6 +19,7 @@ import ftl.test.util.TestHelper.getPath import ftl.test.util.assertThrowsWithMessage import io.mockk.every import io.mockk.mockkObject +import kotlinx.coroutines.runBlocking import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue @@ -1368,6 +1370,25 @@ IosArgs """.trimIndent() IosArgs.load(yaml).validate() } + + @Test + fun `should add flank version to client-details even if client-details is empty`() { + val yaml = """ + gcloud: + test: $testPlansPath + xctestrun-file: $testPlansXctestrun + flank: + skip-test-configuration: pl + """.trimIndent() + + val parsedYml = IosArgs.load(yaml).validate() + + val (matrixMap) = runBlocking { parsedYml.runIosTests() } + assertTrue( + "Not all matrices have the `Flank Version` client-detail", + matrixMap.map.all { it.value.clientDetails!!.containsKey("Flank Version") && it.value.clientDetails!!.containsKey("Flank Revision") } + ) + } } private fun IosArgs.Companion.load(yamlData: String, cli: IosRunCommand? = null): IosArgs =