gradle-spoon-plugin
gradle-spoon-plugin copied to clipboard
Validate Spoon Task Inputs
I have the following code:
spoon {
// The number of separate shards to create.
if (project.hasProperty('spoonNumShards')) {
numShards = project.spoonNumShards
}
// The shardIndex option to specify which shard to run.
if (project.hasProperty('spoonShardIndex')) {
shardIndex = project.spoonShardIndex
}
}
I ran the following command
./gradlew :app:spoonDebugAndroidTest -PspoonNumShards=4 -PspoonShardIndex=0
Expected output:
I/RemoteAndroidTest: Running am instrument -w -r -e shardIndex 0 -e numShards 4 -e log true
Actual output:
I/RemoteAndroidTest: Running am instrument -w -r -e shardIndex 48 -e numShards 52 -e log true
To fix this, Integer.valueOf(..)
is needed.
spoon {
// The number of separate shards to create.
if (project.hasProperty('spoonNumShards')) {
numShards = Integer.valueOf(project.spoonNumShards)
}
// The shardIndex option to specify which shard to run.
if (project.hasProperty('spoonShardIndex')) {
shardIndex = Integer.valueOf(project.spoonShardIndex)
}
}
Ask:
Avoid this issue by having the spoon gradle plugin validate its input and throw an exception when numShards
/shardIndex
, are not integers.
Thanks!
Are you saying that these tests are validating this already? https://github.com/jaredsburrows/gradle-spoon-plugin/blob/master/src/test/groovy/com/jaredsburrows/spoon/SpoonPluginSpec.groovy#L79