Skip to content

Commit

Permalink
Fast fail when full-junit-result and legacy-junit-result (#965)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamfilipow92 authored Aug 11, 2020
1 parent 9dcad04 commit 0a030c7
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
1 change: 1 addition & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [#946](https://github.com/Flank/flank/pull/946) Added tests for flank scripts. ([piotradamczyk5](https://github.com/piotradamczyk5))
- [#935](https://github.com/Flank/flank/pull/935) Process junit xml even when full junit is not enabled. ([kozaxinan](https://github.com/kozaxinan))
- [#962](https://github.com/Flank/flank/pull/962) Make table text left aligned. ([pawelpasterz](https://github.com/pawelpasterz))
- [#965](https://github.com/Flank/flank/pull/965) Fast fail when full-junit-result and legacy-junit-result. ([adamfilipow92](https://github.com/adamfilipow92))
-
-

Expand Down
6 changes: 6 additions & 0 deletions test_runner/src/main/kotlin/ftl/args/ValidateAndroidArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ fun AndroidArgs.validate() {
assertRoboTest()
assertDirectoriesToPull()
assertMaxTestShardsByDeviceType()
assertParametersConflict()
}

private fun AndroidArgs.assertAdditionalAppTestApks() {
Expand Down Expand Up @@ -99,3 +100,8 @@ private fun AndroidArgs.throwMaxTestShardsLimitExceeded(): Nothing {
"max-test-shards must be >= ${IArgs.AVAILABLE_VIRTUAL_SHARD_COUNT_RANGE.first} and <= ${IArgs.AVAILABLE_VIRTUAL_SHARD_COUNT_RANGE.last} for virtual devices, for physical devices max-test-shards must be >= ${IArgs.AVAILABLE_PHYSICAL_SHARD_COUNT_RANGE.first} and <= ${IArgs.AVAILABLE_PHYSICAL_SHARD_COUNT_RANGE.last}, or -1. But current is $maxTestShards"
)
}

private fun AndroidArgs.assertParametersConflict() {
if (useLegacyJUnitResult && fullJUnitResult)
throw FlankConfigurationError("Parameters conflict, you cannot set: `--legacy-junit-result` and `--full-junit-result` at the same time.")
}
68 changes: 68 additions & 0 deletions test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1566,6 +1566,74 @@ AndroidArgs
val args = AndroidArgs.load(yaml)
assertEquals(AVAILABLE_PHYSICAL_SHARD_COUNT_RANGE.last, args.maxTestShards)
}

@Test(expected = FlankConfigurationError::class)
fun `should throw when --legacy-junit-result and --full-junit-result set`() {
val yaml = """
gcloud:
app: $appApk
test: $testApk
device:
- model: blueline
version: 28
locale: en
orientation: portrait
- model: Nexus6
version: 25
locale: en
orientation: portrait
flank:
max-test-shards: -1
full-junit-result: true
legacy-junit-result: true
""".trimIndent()
AndroidArgs.load(yaml)
}
@Test
fun `should not throw when --legacy-junit-result set and --full-junit-result not set`() {
val yaml = """
gcloud:
app: $appApk
test: $testApk
device:
- model: blueline
version: 28
locale: en
orientation: portrait
- model: Nexus6
version: 25
locale: en
orientation: portrait
flank:
max-test-shards: -1
full-junit-result: false
legacy-junit-result: true
""".trimIndent()
AndroidArgs.load(yaml)
}

@Test
fun `should not throw when --legacy-junit-result not set and --full-junit-result set`() {
val yaml = """
gcloud:
app: $appApk
test: $testApk
device:
- model: blueline
version: 28
locale: en
orientation: portrait
- model: Nexus6
version: 25
locale: en
orientation: portrait
flank:
max-test-shards: -1
full-junit-result: true
legacy-junit-result: false
""".trimIndent()
AndroidArgs.load(yaml)
}
}

private fun AndroidArgs.Companion.load(yamlData: String, cli: AndroidRunCommand? = null): AndroidArgs =
Expand Down

0 comments on commit 0a030c7

Please sign in to comment.