-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4cfe399
commit a3ef5d3
Showing
9 changed files
with
241 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
buildSrc/src/main/java/com/osacky/flank/gradle/SanityConfigValidation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.osacky.flank.gradle | ||
|
||
import org.gradle.api.GradleException | ||
import org.gradle.api.provider.ListProperty | ||
import org.gradle.api.provider.Property | ||
|
||
@Throws(GradleException::class) | ||
fun checkIfSanityAndValidateConfigs(config: FladleConfig) = when (config) { | ||
is FlankGradleExtension -> config.checkAndValidateExtension() | ||
is FladleConfigImpl -> config.checkAndValidateConfig() | ||
else -> throw GradleException("Unable to check for sanity, check config type") | ||
} | ||
|
||
private fun FlankGradleExtension.checkAndValidateExtension() { | ||
if (sanityRobo.getOrElse(false)) when { | ||
instrumentationApk.isNotPresentOrBlank -> throwBaseConfigError("instrumentationApk") | ||
additionalTestApks.isNotPresentOrEmpty -> throwBaseConfigError("additionalTestApks") | ||
roboDirectives.isNotPresentOrEmpty -> throwBaseConfigError("roboDirectives") | ||
roboScript.isNotPresentOrBlank -> throwBaseConfigError("roboScript") | ||
} | ||
} | ||
|
||
private fun FladleConfigImpl.checkAndValidateConfig() { | ||
if (sanityRobo.getOrElse(false)) when { | ||
roboDirectives.isNotPresentOrEmpty -> throwAdditionalConfigError("roboDirectives", name) | ||
roboScript.isNotPresentOrBlank -> throwAdditionalConfigError("roboScript", name) | ||
instrumentationApk.isNotPresentOrBlank -> throwAdditionalConfigError("instrumentationApk", name) | ||
additionalTestApks.isNotPresentOrEmpty -> throwAdditionalConfigError("additionalTestApks", name) | ||
} | ||
} | ||
|
||
private fun throwBaseConfigError(option: String): Nothing = | ||
throw GradleException("Incorrect [base] configuration. [$option] can't be used together with sanityRobo.") | ||
|
||
private fun throwAdditionalConfigError(option: String, name: String): Nothing = | ||
throw GradleException( | ||
"Incorrect [$name] configuration. [$option] can't be used together with sanityRobo. " + | ||
"If you want to launch robo test run without robo script place only sanityRoboRun() into [$name] configuration" | ||
) | ||
|
||
private val Property<String>.isNotPresentOrBlank | ||
get() = orNull.isNullOrBlank().not() | ||
|
||
private val <T> ListProperty<T>.isNotPresentOrEmpty | ||
get() = getOrElse(emptyList()).isEmpty().not() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.