Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message on IOS #968

Merged
merged 7 commits into from
Aug 11, 2020
Merged

Improve error message on IOS #968

merged 7 commits into from
Aug 11, 2020

Conversation

Sloox
Copy link
Contributor

@Sloox Sloox commented Aug 10, 2020

Improve error message on IOS when test or xctestrun-file not found
Fixes #937

Test Plan

How do we know the code works?
Tested for the cases where test and xctestrun-file not specified. Instead of an exception an appropriate message that correlates to what is outputted by android is displayed.

Checklist

  • Unit tested
  • release_notes.md updated

release_notes.md Outdated
@@ -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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing message inside

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -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())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could skip this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@piotradamczyk5 piotradamczyk5 self-requested a review August 10, 2020 14:18
piotradamczyk5
piotradamczyk5 previously approved these changes Aug 10, 2020
piotradamczyk5
piotradamczyk5 previously approved these changes Aug 10, 2020
release_notes.md Outdated
@@ -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) Improve error message on IOS when test or xctestrun-file not found ([sloox](https://github.com/Sloox))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [#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))

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

xctestrunFile is not nullable so .orEmpty() is redundant here.

@@ -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 (xctestrunFile.isNullOrBlank() or xctestrunZip.isNullOrBlank())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isBlank() should be enough in both cases

Copy link
Contributor

@adamfilipow92 adamfilipow92 Aug 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this file, we have two logic operator convention now. Look:

private fun IosArgs.assertMaxTestShards() { this.maxTestShards
    if (
        maxTestShards !in IArgs.AVAILABLE_PHYSICAL_SHARD_COUNT_RANGE &&
        maxTestShards != -1
    ) throw FlankConfigurationError(
        "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 (xctestrunFile.isNullOrBlank() or 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
    else -> throw IncompatibleTestDimensionError(("Xcode $xcodeVersion is not a supported Xcode version"))
}

Maybe we should decide and keep only one?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 @adamfilipow92 we can consider it in another issue. This PR name is Improve error message on IOS not Android

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, my mistake. I update my comment to iOS version.

Copy link
Contributor Author

@Sloox Sloox Aug 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall i create a ticket for this @jan-gogo @adamfilipowicz92 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Sloox hehe, ofc not if it is only about style convention ;). It is minor for me, you can leave it as-is if you find it readable or fix if you want.

@Sloox Sloox merged commit 2d7df89 into master Aug 11, 2020
@Sloox Sloox deleted the #937-improve-ios-test-errors branch August 11, 2020 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve error message on iOS when test or xctestrun-file not set
5 participants