-
Notifications
You must be signed in to change notification settings - Fork 37
Conversation
Define an Action in the extension to configure it.
Change the categories to have more meaningful sample
protected handleCommandOutput(def text) { | ||
super.handleCommandOutput(text) | ||
if (text.contains("Monkey aborted")) { | ||
if (text.toLowerCase().contains("monkey aborted")) { |
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.
Here, this was kinda a hack
to fail the build if the monkey is aborted.
Monkey's output sometimes starts with upper case Monkey
, sometimes starts with some other message that ends with lower case monkey
.
So now it will fail whatever the case.
// prefer system property over direct setting to enable commandline arguments | ||
def getCategories() { | ||
def systemCategories = System.properties['categories'] | ||
systemCategories ? [systemCategories] : categories |
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.
Here this also fixes a problem with command line argument support.
Basically command line support for categories was never working.
This command ./gradlew monkeyFreeBetaDebug -i -Dcategories=test
would resolve into this output
[adb, -s, 02c2095608e77be5, shell, monkey, -p, com.novoda.gradle.command, -c, t, -c, e, -c, s, -c, t, -v, 1000]
It basically splits the given String into pieces.
Now only when the command line argument is provided, I am putting it into an array.
…he monkey object.
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.
Looks good! 👍
this.events = events | ||
} | ||
|
||
void seed(seed) { |
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.
Is this needed at all?
For lists we need the overwrite, I'm not sure about simple values.
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.
Sorry it didn't work. It looks for the method seed
and errors. This magically works with the fields in Extension 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.
Ah, okay. Fine then. 👍
// prefer system property over direct setting to enable commandline arguments | ||
def getCategories() { | ||
System.properties['categories'] ?: categories | ||
public void monkey(Action<MonkeySpec> action) { |
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.
public
is the default, no need to specify it here.
def getCategories() { | ||
System.properties['categories'] ?: categories | ||
public void monkey(Action<MonkeySpec> action) { | ||
action.execute(monkey); |
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.
No ;
needed. 👅
This PR fixes #105
There are still things to improve how we setup our tasks but this PR is the first step to have more gradle DSL like setup for the config of the tasks.
Monkey
task class.MonkeySpec
class.MonkeySpec
is always initialized but its internals are set using theAction
class of gradle.monkey
field in the extension.monkey
. (Can be seen in the sample)Depending on the decision here, we may have a follow-up PR to support to old configuration still.
Having the change documented well could also be enough. If we break the API, the upgraded version of the plugin will break the build which then can be easily fixed.
Bonus
This also works and it is great for simple configurations.
as opposed to this from the sample
command { monkey { events 1000 } }