diff --git a/release_notes.md b/release_notes.md index 47e6ca71a6..c3c4d18583 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,4 +1,5 @@ ## next (unreleased) +- [#991](https://github.com/Flank/flank/pull/991) Fail fast on orientation mispell ([sloox](https://github.com/Sloox)) - [#992](https://github.com/Flank/flank/pull/992) Update google api. ([jan-gogo](https://github.com/jan-gogo)) - [#987](https://github.com/Flank/flank/pull/987) Flank Error Monitoring readme addition ([sloox](https://github.com/Sloox)) - [#990](https://github.com/Flank/flank/pull/990) Fix: exclusion of @Suppress test. ([piotradamczyk5](https://github.com/piotradamczyk5)) diff --git a/test_runner/src/main/kotlin/ftl/args/ValidateCommonArgs.kt b/test_runner/src/main/kotlin/ftl/args/ValidateCommonArgs.kt index 25e7997498..656220d4d9 100644 --- a/test_runner/src/main/kotlin/ftl/args/ValidateCommonArgs.kt +++ b/test_runner/src/main/kotlin/ftl/args/ValidateCommonArgs.kt @@ -1,15 +1,28 @@ package ftl.args +import ftl.config.Device import ftl.config.FtlConstants import ftl.util.FlankConfigurationError +import ftl.util.FlankGeneralError fun CommonArgs.validate() { assertProjectId() assertShardTime() assertRepeatTests() assertSmartFlankGcsPath() + assertOrientationCorrectness() } +private fun List.devicesWithMispeltOrientations(availableOrientations: List) = + filter { it.orientation !in availableOrientations } + +private fun CommonArgs.assertOrientationCorrectness() = + devices.devicesWithMispeltOrientations(listOf("portrait", "landscape", "default")).throwIfAnyMisspelt() + +private fun List.throwIfAnyMisspelt() = + if (isNotEmpty()) throw FlankGeneralError("Orientation misspelled or incorrect, found\n${joinToString(separator = "\n")} \nAborting.") + else Unit + private fun CommonArgs.assertProjectId() { if (project.isEmpty()) throw FlankConfigurationError( "The project is not set. Define GOOGLE_CLOUD_PROJECT, set project in flank.yml\n" + diff --git a/test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt b/test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt index 91de23aad3..8b8da6bb88 100644 --- a/test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt +++ b/test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt @@ -1634,6 +1634,48 @@ AndroidArgs """.trimIndent() AndroidArgs.load(yaml) } + + @Test + fun `proceed on correct orientation`() { + val yaml = """ + gcloud: + app: $appApk + test: $testApk + device: + - model: Nexus6 + version: 25 + locale: en + orientation: portrait + - model: Nexus6 + version: 25 + locale: en + orientation: default + - model: Nexus6 + version: 25 + locale: en + orientation: landscape + flank: + max-test-shards: -1 + """.trimIndent() + AndroidArgs.load(yaml) + } + + @Test(expected = FlankGeneralError::class) + fun `fail fast on orientation misspell`() { + val yaml = """ + gcloud: + app: $appApk + test: $testApk + device: + - model: blueline + version: 28 + locale: en + orientation: poortrait + flank: + max-test-shards: -1 + """.trimIndent() + AndroidArgs.load(yaml) + } } private fun AndroidArgs.Companion.load(yamlData: String, cli: AndroidRunCommand? = null): AndroidArgs = diff --git a/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt b/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt index b1a5183a41..b29ae89aae 100644 --- a/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt +++ b/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt @@ -57,11 +57,11 @@ class IosArgsTest { - model: iphone8 version: 11.2 locale: c - orientation: d + orientation: default - model: iphone8 version: 11.2 locale: c - orientation: d + orientation: default num-flaky-test-attempts: 4 flank: @@ -159,7 +159,7 @@ flank: // IosGcloudYml assert(xctestrunZip, testAbsolutePath) assert(xctestrunFile, xctestrunFileAbsolutePath) - val device = Device("iphone8", "11.2", "c", "d") + val device = Device("iphone8", "11.2", "c", "default") assert(xcodeVersion ?: "", "9.2") assert(devices, listOf(device, device)) @@ -206,11 +206,11 @@ IosArgs - model: iphone8 version: 11.2 locale: c - orientation: d + orientation: default - model: iphone8 version: 11.2 locale: c - orientation: d + orientation: default num-flaky-test-attempts: 4 flank: