From 4258f24db0f1acd389921be5a03076b425820879 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Mon, 10 Aug 2020 14:34:05 +0200 Subject: [PATCH 1/7] Improve error message on IOS when test or xctestrun-file not found --- .../src/main/kotlin/ftl/args/IosArgs.kt | 2 +- .../main/kotlin/ftl/args/ValidateIosArgs.kt | 5 ++ .../src/test/kotlin/ftl/args/IosArgsTest.kt | 47 ++++++++++++++++++- 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/test_runner/src/main/kotlin/ftl/args/IosArgs.kt b/test_runner/src/main/kotlin/ftl/args/IosArgs.kt index fdf625b3db..489d362606 100644 --- a/test_runner/src/main/kotlin/ftl/args/IosArgs.kt +++ b/test_runner/src/main/kotlin/ftl/args/IosArgs.kt @@ -62,7 +62,7 @@ IosArgs private fun IosArgs.calculateShardChunks() = if (disableSharding) listOf(emptyList()) else ArgsHelper.calculateShards( - filteredTests = filterTests(findTestNames(xctestrunFile), testTargets) + filteredTests = filterTests(findTestNames(xctestrunFile.orEmpty()), testTargets) .distinct() .map { FlankTestMethod(it, ignored = false) }, args = this diff --git a/test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt b/test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt index 24e009bd08..115535dcdb 100644 --- a/test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt +++ b/test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt @@ -7,6 +7,7 @@ import ftl.util.IncompatibleTestDimensionError fun IosArgs.validate() { assertXcodeSupported() assertDevicesSupported() + assertTestTypes() assertMaxTestShards() } private fun IosArgs.assertMaxTestShards() { this.maxTestShards @@ -17,6 +18,10 @@ private fun IosArgs.assertMaxTestShards() { this.maxTestShards "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 IosArgs.assertTestTypes() { + if(this.xctestrunFile.isNullOrBlank() or this.xctestrunZip.isNullOrBlank()) + throw FlankConfigurationError("Both of following options must be specified [test, xctestrun-file].") +} private fun IosArgs.assertXcodeSupported() = when { xcodeVersion == null -> Unit IosCatalog.supportedXcode(xcodeVersion, project) -> Unit diff --git a/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt b/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt index d5bed89f3d..51912a6739 100644 --- a/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt +++ b/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt @@ -916,6 +916,51 @@ IosArgs val args = IosArgs.load(yaml) assertEquals(IArgs.AVAILABLE_PHYSICAL_SHARD_COUNT_RANGE.last, args.maxTestShards) } + + @Test(expected = FlankConfigurationError::class) + fun `verify appropriate error message when test and xctestrun not set`() { + val yaml = """ + gcloud: + flank: + max-test-shards: -1 + """.trimIndent() + val args = IosArgs.load(yaml) + } + + @Test(expected = FlankConfigurationError::class) + fun `verify appropriate error message when xctestrun not set`() { + val yaml = """ + gcloud: + test: $testPath + flank: + max-test-shards: -1 + """.trimIndent() + val args = IosArgs.load(yaml) + } + + @Test(expected = FlankConfigurationError::class) + fun `verify appropriate error message when test not set`() { + val yaml = """ + gcloud: + xctestrun-file: $testPath + flank: + max-test-shards: -1 + """.trimIndent() + val args = IosArgs.load(yaml) + } + + @Test + fun `verify no error message when test and xctestrun-file set`() { + val yaml = """ + gcloud: + test: $testPath + xctestrun-file: $testPath + flank: + max-test-shards: -1 + """.trimIndent() + val args = IosArgs.load(yaml) + } } -private fun IosArgs.Companion.load(yamlData: String, cli: IosRunCommand? = null): IosArgs = load(StringReader(yamlData), cli) +private fun IosArgs.Companion.load(yamlData: String, cli: IosRunCommand? = null): IosArgs = + load(StringReader(yamlData), cli) From 1a5ad2b5e367a0d4bffd1b3e552d061652e4800b Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Mon, 10 Aug 2020 14:43:52 +0200 Subject: [PATCH 2/7] Update release_notes.md --- release_notes.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/release_notes.md b/release_notes.md index 20f22d1c21..f8a2e41aed 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,5 +1,6 @@ ## next (unreleased) -- [#952](https://github.com/Flank/flank/pull/952) Fix version printing on Flank release +- [#937](https://github.com/Flank/flank/pull/968) ([sloox](https://github.com/Sloox)) +- [#952](https://github.com/Flank/flank/pull/952) Fix version printing on Flank release ([sloox](https://github.com/Sloox)) - [#950](https://github.com/Flank/flank/pull/950) Fix crash when --legacy-junit-result set. ([adamfilipow92](https://github.com/adamfilipow92)) - [#948](https://github.com/Flank/flank/pull/948) Increment retry tries and change sync tag for jfrogSync. ([piotradamczyk5](https://github.com/piotradamczyk5)) - [#946](https://github.com/Flank/flank/pull/946) Added tests for flank scripts. ([piotradamczyk5](https://github.com/piotradamczyk5)) From 367d6ce33900de656be35f6b35bc506e7cb4be50 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Mon, 10 Aug 2020 15:16:12 +0200 Subject: [PATCH 3/7] Fix detekt issue --- test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt b/test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt index 115535dcdb..136e781b62 100644 --- a/test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt +++ b/test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt @@ -19,7 +19,7 @@ private fun IosArgs.assertMaxTestShards() { this.maxTestShards ) } private fun IosArgs.assertTestTypes() { - if(this.xctestrunFile.isNullOrBlank() or this.xctestrunZip.isNullOrBlank()) + if (this.xctestrunFile.isNullOrBlank() or this.xctestrunZip.isNullOrBlank()) throw FlankConfigurationError("Both of following options must be specified [test, xctestrun-file].") } private fun IosArgs.assertXcodeSupported() = when { From 73ac521fe088879f030ade300f6b3f906ee74bef Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Mon, 10 Aug 2020 15:41:38 +0200 Subject: [PATCH 4/7] PR Fixes, Removal of this, update release notes with message --- release_notes.md | 2 +- test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/release_notes.md b/release_notes.md index f8a2e41aed..5de1877a38 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,5 +1,5 @@ ## next (unreleased) -- [#937](https://github.com/Flank/flank/pull/968) ([sloox](https://github.com/Sloox)) +- [#937](https://github.com/Flank/flank/pull/968) Improve error message on IOS when test or xctestrun-file not found ([sloox](https://github.com/Sloox)) - [#952](https://github.com/Flank/flank/pull/952) Fix version printing on Flank release ([sloox](https://github.com/Sloox)) - [#950](https://github.com/Flank/flank/pull/950) Fix crash when --legacy-junit-result set. ([adamfilipow92](https://github.com/adamfilipow92)) - [#948](https://github.com/Flank/flank/pull/948) Increment retry tries and change sync tag for jfrogSync. ([piotradamczyk5](https://github.com/piotradamczyk5)) diff --git a/test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt b/test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt index 136e781b62..a8807eba4f 100644 --- a/test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt +++ b/test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt @@ -19,7 +19,7 @@ private fun IosArgs.assertMaxTestShards() { this.maxTestShards ) } private fun IosArgs.assertTestTypes() { - if (this.xctestrunFile.isNullOrBlank() or this.xctestrunZip.isNullOrBlank()) + if (xctestrunFile.isNullOrBlank() or xctestrunZip.isNullOrBlank()) throw FlankConfigurationError("Both of following options must be specified [test, xctestrun-file].") } private fun IosArgs.assertXcodeSupported() = when { From e6af1f51ab7234c7d189b772daa0d19e357c55cf Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Mon, 10 Aug 2020 16:44:24 +0200 Subject: [PATCH 5/7] Remove the warning about unused args --- test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt b/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt index 51912a6739..b1a5183a41 100644 --- a/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt +++ b/test_runner/src/test/kotlin/ftl/args/IosArgsTest.kt @@ -924,7 +924,7 @@ IosArgs flank: max-test-shards: -1 """.trimIndent() - val args = IosArgs.load(yaml) + IosArgs.load(yaml) } @Test(expected = FlankConfigurationError::class) @@ -935,7 +935,7 @@ IosArgs flank: max-test-shards: -1 """.trimIndent() - val args = IosArgs.load(yaml) + IosArgs.load(yaml) } @Test(expected = FlankConfigurationError::class) @@ -946,7 +946,7 @@ IosArgs flank: max-test-shards: -1 """.trimIndent() - val args = IosArgs.load(yaml) + IosArgs.load(yaml) } @Test @@ -958,7 +958,7 @@ IosArgs flank: max-test-shards: -1 """.trimIndent() - val args = IosArgs.load(yaml) + IosArgs.load(yaml) } } From ec63b203c2e735cb6558aee60dd2b0e9c7c4dca7 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Tue, 11 Aug 2020 10:22:34 +0200 Subject: [PATCH 6/7] IOS renamed to iOS --- release_notes.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_notes.md b/release_notes.md index 5de1877a38..60eba1f62b 100644 --- a/release_notes.md +++ b/release_notes.md @@ -1,5 +1,5 @@ ## next (unreleased) -- [#937](https://github.com/Flank/flank/pull/968) Improve error message on IOS when test or xctestrun-file not found ([sloox](https://github.com/Sloox)) +- [#937](https://github.com/Flank/flank/pull/968) Improve error message on iOS when test or xctestrun-file not found ([sloox](https://github.com/Sloox)) - [#952](https://github.com/Flank/flank/pull/952) Fix version printing on Flank release ([sloox](https://github.com/Sloox)) - [#950](https://github.com/Flank/flank/pull/950) Fix crash when --legacy-junit-result set. ([adamfilipow92](https://github.com/adamfilipow92)) - [#948](https://github.com/Flank/flank/pull/948) Increment retry tries and change sync tag for jfrogSync. ([piotradamczyk5](https://github.com/piotradamczyk5)) From 9dfbb82ea815b215939f2b7d66813a7d3a199d28 Mon Sep 17 00:00:00 2001 From: Michael Wright Date: Tue, 11 Aug 2020 12:30:38 +0200 Subject: [PATCH 7/7] Removed isNotNull & orEmpty as per PR request --- test_runner/src/main/kotlin/ftl/args/IosArgs.kt | 2 +- test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test_runner/src/main/kotlin/ftl/args/IosArgs.kt b/test_runner/src/main/kotlin/ftl/args/IosArgs.kt index 489d362606..fdf625b3db 100644 --- a/test_runner/src/main/kotlin/ftl/args/IosArgs.kt +++ b/test_runner/src/main/kotlin/ftl/args/IosArgs.kt @@ -62,7 +62,7 @@ IosArgs private fun IosArgs.calculateShardChunks() = if (disableSharding) listOf(emptyList()) else ArgsHelper.calculateShards( - filteredTests = filterTests(findTestNames(xctestrunFile.orEmpty()), testTargets) + filteredTests = filterTests(findTestNames(xctestrunFile), testTargets) .distinct() .map { FlankTestMethod(it, ignored = false) }, args = this diff --git a/test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt b/test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt index a8807eba4f..561c1f9c92 100644 --- a/test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt +++ b/test_runner/src/main/kotlin/ftl/args/ValidateIosArgs.kt @@ -19,7 +19,7 @@ private fun IosArgs.assertMaxTestShards() { this.maxTestShards ) } private fun IosArgs.assertTestTypes() { - if (xctestrunFile.isNullOrBlank() or xctestrunZip.isNullOrBlank()) + if (xctestrunFile.isBlank() or xctestrunZip.isBlank()) throw FlankConfigurationError("Both of following options must be specified [test, xctestrun-file].") } private fun IosArgs.assertXcodeSupported() = when {