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! |
runningcode
left a comment
There was a problem hiding this comment.
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.
31ea174 to
779ca80
Compare
0671480 to
4cfe399
Compare
|
As discussed with @runningcode, changing approach a bit
|
ac2ba00 to
a3ef5d3
Compare
runningcode
left a comment
There was a problem hiding this comment.
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.
| 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.
shouldn't we be passing the value from the base here?
There was a problem hiding this comment.
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.
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
runningcode
left a comment
There was a problem hiding this comment.
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!
| 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.
can we make this change separately? How does it affect the performance of the tests?
There was a problem hiding this comment.
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.
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.
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.
shouldn't we throw an error here if sanityRobo is true?
There was a problem hiding this comment.
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
| override val fullJunitResult: Property<Boolean> | ||
| ) : FladleConfig | ||
| ) : FladleConfig { | ||
| fun sanityRoboRun() { |
There was a problem hiding this comment.
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?
| } | ||
|
|
||
| internal fun writeAdditionalProperties(config: FladleConfig): String = buildString { | ||
| internal fun writeAdditionalProperties(config: FladleConfig, printRobo: Boolean = true): String = buildString { |
There was a problem hiding this comment.
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.
Actually, I can remove this logic entirely since now we have sanityRobo in FladleConfig
| } | ||
|
|
||
| @Test | ||
| fun `test auto configuration with sanityRobo set (base config)`() { |
f602526 to
65213bd
Compare
|
Hey @runningcode , ready for another review round :) |
runningcode
left a comment
There was a problem hiding this comment.
Alright, looking very good. Another round of comments and hopefully we can merge this very soon.
| // 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.
let's move this to be the first line in createTasksForConfig
that way the next line can be removed as well.
| 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.
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.
| "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.
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.
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.
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 { |
|
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
-PsanityRoboto gradle commandWith this property,
fladleshould skip appending config yaml file withrobo-directives,robo-script,test,additional-app-test-apksExample:
./gradlew -p sample-kotlin writeConfigProps -PsanityRobofrom project roottest)