Skip to content

Implement lazy properties#176

Merged
runningcode merged 7 commits into
runningcode:masterfrom
pawelpasterz:lazy-property-v2
Sep 26, 2020
Merged

Implement lazy properties#176
runningcode merged 7 commits into
runningcode:masterfrom
pawelpasterz:lazy-property-v2

Conversation

@pawelpasterz

@pawelpasterz pawelpasterz commented Sep 23, 2020

Copy link
Copy Markdown
Contributor

This will fix #92

What was done?

  1. Implement all remaining properties to use lazy API.
  2. small refactor

What was not done?

  1. there is a test failing (locally) ConfigurationCacheTest#runFlank (it is also falling on the master branch)
  2. update with latest flank's command
  3. enable to run robo test without robo script
  4. refactor of YamlWriterTest

I decided to left above as they are since the scope of this PR is rather big

@pawelpasterz

Copy link
Copy Markdown
Contributor Author

Hey, @runningcode please take a look, thanks!

Comment thread build.gradle Outdated
Comment thread buildSrc/src/main/java/com/osacky/flank/gradle/FladleConfig.kt Outdated

@runningcode runningcode left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Looking good. just some small logic changes I noticed. I haven't finished my review though.

Comment thread sample/build.gradle
Comment thread sample/build.gradle
Comment thread docs/configuration.md
Comment thread buildSrc/src/main/java/com/osacky/flank/gradle/YamlWriter.kt Outdated
Comment thread buildSrc/src/main/java/com/osacky/flank/gradle/YamlWriter.kt Outdated
}
check(base.debugApk.isPresent) { "debugApk must be specified" }
check(base.instrumentationApk.isPresent xor !base.roboScript.isNullOrBlank()) {
check(base.instrumentationApk.isPresent xor base.roboScript.isPresent) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

the previous logic checked if the roboScript was not null and not blank. Should we check that here as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TBH I based my implementation on instrumentationApk check, but yeah, for now we should check for path being blank as well.

FYI, this will change with #165

appendln(" test: ${base.instrumentationApk.get()}")
}
appendln(deviceString)
if (config.devices.isPresentAndNotEmpty) appendln(createDeviceString(config.devices.get()))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Is the device a required property in flank? What would happen if it were omitted?

I believe the previous logic would alway add it, this logic only add it if it is present. Why the change?

@pawelpasterz pawelpasterz Sep 23, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually not, we can omit devices and NexusLowRes will be taken as default. TBH the only required properties (from flank's perspective) are app apk and test apk. I have in my mind to change it in fladle but in separate PR

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

But I can change implementation to reflect the previous one, and change it with another PR

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Makes sense. What version of the API/Android SDK does Flank use? I want to ensure that there are no unexpected changes introduced with this change.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. What version of the API/Android SDK does Flank use? I want to ensure that there are no unexpected changes introduced with this change.

28

https://github.com/Flank/flank/blob/master/test_runner/src/main/kotlin/ftl/config/FtlConstants.kt#L47-L48

@runningcode runningcode left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Two more questions.
There are a lot of large customers of fladle, and I just want to make sure not to introduce any unexpected changes.

appendln(" test: ${base.instrumentationApk.get()}")
}
appendln(deviceString)
if (config.devices.isPresentAndNotEmpty) appendln(createDeviceString(config.devices.get()))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Makes sense. What version of the API/Android SDK does Flank use? I want to ensure that there are no unexpected changes introduced with this change.

@runningcode runningcode left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Alright, we're getting pretty close. Sorry its a big PR and its taking me a while to get through. :)
Here's another round of comments.

extension.debugApk.set([email protected])
}
if (extension.roboScript == null && !extension.instrumentationApk.isPresent) {
if (!extension.roboScript.isPresent && !extension.instrumentationApk.isPresent) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

in order to maintain the same logic as before, i think this should be:

Suggested change
if (!extension.roboScript.isPresent && !extension.instrumentationApk.isPresent) {
if (extension.roboScript.orNull == null && !extension.instrumentationApk.isPresent) {

override var devices: List<Map<String, String>> = listOf(mapOf("model" to "NexusLowRes", "version" to "28"))
override val useOrchestrator: Property<Boolean> = objects.property<Boolean>().convention(false)
override val autoGoogleLogin: Property<Boolean> = objects.property<Boolean>().convention(false)
override val devices: ListProperty<Map<String, String>> = objects.listProperty<Map<String, String>>().convention(listOf(mapOf("model" to "NexusLowRes", "version" to "28")))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

thanks for keeping this here. perhaps we can remove it in a separate PR.

resultsBucket = resultsBucket,
keepFilePath = keepFilePath,
resultsDir = resultsDir,
useOrchestrator = objects.property<Boolean>().convention(useOrchestrator),

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

thanks for changing all of these! 👍

}
check(base.debugApk.isPresent) { "debugApk must be specified" }
check(base.instrumentationApk.isPresent xor !base.roboScript.isNullOrBlank()) {
check(base.instrumentationApk.isPresent xor !base.roboScript.orNull.isNullOrBlank()) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍

appendln(" test: ${base.instrumentationApk.get()}")
}
appendln(deviceString)
if (config.devices.isPresentAndNotEmpty) appendln(createDeviceString(config.devices.get()))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

i think this isPresentAndNotEmpty can be removed now.

appendln(" output-style: ${config.outputStyle.get()}")
appendProperty(config.testShards, name = "max-test-shards")
appendProperty(config.shardTime, name = "shard-time")
appendProperty(config.repeatTests, name = "num-test-runs")

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

nice cleanup here

Comment on lines +102 to +103
private fun <T> StringBuilder.appendListProperty(
prop: ListProperty<T>,

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

In this case, I believe the list property must always be of type string. Can we restrict the API in that way in order to prevent it from being abused or having unintended effects?

Suggested change
private fun <T> StringBuilder.appendListProperty(
prop: ListProperty<T>,
private fun StringBuilder.appendListProperty(
prop: ListProperty<String>,


config.roboScript?.let {
appendln(" robo-script: $it")
private fun <T, K> StringBuilder.appendMapProperty(

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

In this case, I believe the map property must always be of type string. Can we restrict the API in that way in order to prevent it from being abused or having unintended effects?

Suggested change
private fun <T, K> StringBuilder.appendMapProperty(
private fun StringBuilder.appendMapProperty(

@runningcode
runningcode merged commit 041c8c3 into runningcode:master Sep 26, 2020
@runningcode

Copy link
Copy Markdown
Owner

Thanks @pawelpasterz for doing this! i know it was a lot of work!

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.

Use lazy configuration and lazy properties for configuring Fladle

2 participants