-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Support roboTest without roboScript (sanityRobo) #177
Support roboTest without roboScript (sanityRobo) #177
Conversation
17f39ee
to
4978a4b
Compare
Hey @runningcode please, take a look and let me know what do you think Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @pawelpasterz. Thanks very much for doing this. A lot of people have been asking for this feature.
I also really appreciate the thorough tests.
buildSrc/src/main/java/com/osacky/flank/gradle/FladlePluginDelegate.kt
Outdated
Show resolved
Hide resolved
buildSrc/src/test/java/com/osacky/flank/gradle/integration/SanityRoboCheck.kt
Outdated
Show resolved
Hide resolved
buildSrc/src/test/java/com/osacky/flank/gradle/integration/TestFixtures.kt
Outdated
Show resolved
Hide resolved
buildSrc/src/test/java/com/osacky/flank/gradle/integration/TestFixtures.kt
Outdated
Show resolved
Hide resolved
buildSrc/src/test/java/com/osacky/flank/gradle/integration/SanityRoboCheck.kt
Outdated
Show resolved
Hide resolved
31ea174
to
779ca80
Compare
buildSrc/src/test/java/com/osacky/flank/gradle/integration/SanityRoboCheck.kt
Outdated
Show resolved
Hide resolved
0671480
to
4cfe399
Compare
As discussed with @runningcode, changing approach a bit
|
ac2ba00
to
a3ef5d3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i haven't finished looking but just some comments! looks pretty good. i will make some suggestions on the error messages in my next pass.
@@ -115,6 +80,9 @@ open class FlankGradleExtension @Inject constructor(objects: ObjectFactory) : Fl | |||
name = it, | |||
projectId = objects.property<String>().convention(projectId), | |||
serviceAccountCredentials = objects.fileProperty().convention(serviceAccountCredentials), | |||
debugApk = objects.property<String>().convention(debugApk), | |||
instrumentationApk = objects.property<String>().convention(instrumentationApk), | |||
sanityRobo = objects.property<Boolean>().convention(false), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we be passing the value from the base here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we shouldn't. Assuming we have sanityRobo = true
in the base config that would propagate this to the additional configs. My idea was, every config has it's own sanityRobo
value (default false) that is independent of the rest. I am thinking about the case when user want runFlank
to be sanity robo test and all the rest (runFlank[name1]
, runFlank[name2]
) are 'normal' test runs
Of course, I can change it to behave otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You make a good point here. I think we want consistency though. All other values are inherited. We shouldn't assume that users will not try to have multiple different sanityRobo
configs which inherit from the base.
Let's pass the value from the base here as well.
8dee5d4
to
f726143
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice. I went through all of it. I had a few questions about the test cases and error messages but otherwise the overall approach looks like what we want!
buildSrc/build.gradle.kts
Outdated
@@ -153,6 +153,7 @@ fun org.gradle.api.publish.maven.MavenPom.configureForFladle(pluginName: String) | |||
tasks.withType(Test::class.java).configureEach { | |||
// Test fixtures are stored in here so we should re-run tests if the test projects change. | |||
inputs.dir("src/test/resources") | |||
maxParallelForks = Runtime.getRuntime().availableProcessors() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make this change separately? How does it affect the performance of the tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make this change separately?
sure
How does it affect the performance of the tests?
On my machine, ./gradlew test
took 1m 41s (without parallelism) and 1m 10s (with parallelism)
So it's not something crucial (IMO) but a nice-to-have feature.
|
||
private fun FladleConfigImpl.checkAndValidateConfig() { | ||
if (sanityRobo.getOrElse(false)) when { | ||
roboDirectives.isNotPresentOrEmpty -> throwAdditionalConfigError("roboDirectives", name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is the ordering different for the property validation?
can we make both methods the same and just replace an empty base config name ""
with base
?
Although base
could be the name of the configuration. I don't have a better idea though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, nice catch. This is old implementation before I've added some new properties to FladleConfig
, thanks!
if (base.instrumentationApk.isPresent) { | ||
appendln(" test: ${base.instrumentationApk.get()}") | ||
appendln(" app: ${config.debugApk.get()}") | ||
// We don't want to print instrumentation apks if sanityRobo == true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we throw an error here if sanityRobo is true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sanity run validation if the user sets instrumentationApk
explicitly and this occurs before findDebugAndInstrumentationApk
(autodetection ) is invoked (in FlankPluginDelegate
). The autodetection feature sets app apk and test apk only for base
config and then those values are used for inner (or would should I name those additional ?) configs.
So actually this is applicable only for case when base
config is intended to be sanity robo run and the rest 'normal'
Logic could be simplified if we would agree that base
config can't be sanity robo
buildSrc/src/test/java/com/osacky/flank/gradle/integration/SanityRoboTest.kt
Show resolved
Hide resolved
@@ -45,4 +48,12 @@ data class FladleConfigImpl( | |||
override val outputStyle: Property<String>, | |||
override val legacyJunitResult: Property<Boolean>, | |||
override val fullJunitResult: Property<Boolean> | |||
) : FladleConfig | |||
) : FladleConfig { | |||
fun sanityRoboRun() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this method. Its a good compromise!
Can we rename it to clearPropertiesForSanityRobo()
? And add a bit of javadoc explaining which fields are being cleared?
@@ -57,7 +62,7 @@ internal class YamlWriter { | |||
appendProperty(config.outputStyle, name = "output-style") | |||
} | |||
|
|||
internal fun writeAdditionalProperties(config: FladleConfig): String = buildString { | |||
internal fun writeAdditionalProperties(config: FladleConfig, printRobo: Boolean = true): String = buildString { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of having a boolean passed in to this function, maybe we can just separate it in to two functions? I think that would make the code more readable.
i have an intrinsic dislike of boolean parameters to functions 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, I can remove this logic entirely since now we have sanityRobo
in FladleConfig
buildSrc/src/test/java/com/osacky/flank/gradle/integration/SanityRoboTest.kt
Show resolved
Hide resolved
} | ||
|
||
@Test | ||
fun `test auto configuration with sanityRobo set (base config)`() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice test. thank you!
f602526
to
65213bd
Compare
Hey @runningcode , ready for another review round :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, looking very good. Another round of comments and hopefully we can merge this very soon.
@@ -40,6 +40,9 @@ class FladlePluginDelegate { | |||
// Must be done afterEvaluate otherwise extension values will not be set. | |||
project.dependencies.add(FLADLE_CONFIG, "${base.flankCoordinates.get()}:${base.flankVersion.get()}") | |||
|
|||
checkIfSanityAndValidateConfigs(base) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's move this to be the first line in createTasksForConfig
that way the next line can be removed as well.
@@ -115,6 +80,9 @@ open class FlankGradleExtension @Inject constructor(objects: ObjectFactory) : Fl | |||
name = it, | |||
projectId = objects.property<String>().convention(projectId), | |||
serviceAccountCredentials = objects.fileProperty().convention(serviceAccountCredentials), | |||
debugApk = objects.property<String>().convention(debugApk), | |||
instrumentationApk = objects.property<String>().convention(instrumentationApk), | |||
sanityRobo = objects.property<Boolean>().convention(false), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You make a good point here. I think we want consistency though. All other values are inherited. We shouldn't assume that users will not try to have multiple different sanityRobo
configs which inherit from the base.
Let's pass the value from the base here as well.
} | ||
is FladleConfigImpl -> config.checkAndValidateConfig(config.name) { option, name -> | ||
"Incorrect [$name] configuration. [$option] can't be used together with sanityRobo. " + | ||
"If you want to launch robo test run without robo script place only clearPropertiesForSanityRobo() into [$name] configuration" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"If you want to launch robo test run without robo script place only clearPropertiesForSanityRobo() into [$name] configuration" | |
"To configure sanityRobo, add clearPropertiesForSanityRobo() into [$name] configuration" |
I'm changing the wording here a bit because a robo test run could also be with the robo directives. In that case, these instructions could be confusing. Let's refer specifically to sanityRobo
here.
"Incorrect [$name] configuration. [$option] can't be used together with sanityRobo. " + | ||
"If you want to launch robo test run without robo script place only clearPropertiesForSanityRobo() into [$name] configuration" | ||
} | ||
else -> throw GradleException("Unable to check for sanity, check config type") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's throw an IllegalStateException
and add the config
's class name (or just toString()
to the message.
This will help with debugging down the line.
|
||
private fun FladleConfig.checkAndValidateConfig(name: String = "base", message: (String, String) -> String) { | ||
if (sanityRobo.getOrElse(false)) when { | ||
roboDirectives.isNotPresentOrEmpty -> throw GradleException(message("roboDirectives", name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think an IllegalArgumentException
might be better here.
} | ||
|
||
private fun FladleConfig.checkAndValidateConfig(name: String = "base", message: (String, String) -> String) { | ||
if (sanityRobo.getOrElse(false)) when { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should just get the default value since it is already set to false
. Adding a getOrElse(false)
here is like adding a second default value.
if (sanityRobo.getOrElse(false)) when { | |
if (sanityRobo.get()) when { |
buildSrc/src/test/java/com/osacky/flank/gradle/integration/SanityRoboTest.kt
Show resolved
Hide resolved
buildSrc/src/test/java/com/osacky/flank/gradle/integration/SanityRoboTest.kt
Show resolved
Hide resolved
I'm going to merge and fix the rest of the comments on master so we can release this! |
Fixes #165
Flank supports roboTest without roboScript (sanityRobo) Flank/flank#1108
TO BE UPDATED
To run sanity robo test add
-PsanityRobo
to gradle commandWith this property,
fladle
should skip appending config yaml file withrobo-directives
,robo-script
,test
,additional-app-test-apks
Example:
./gradlew -p sample-kotlin writeConfigProps -PsanityRobo
from project roottest
)