Closed Bug 1204565 Opened 9 years ago Closed 9 years ago

Provide intelligent gradle unit test options

Categories

(Firefox for Android Graveyard :: Android Sync, defect)

defect
Not set
normal

Tracking

(firefox43 fixed)

RESOLVED FIXED
Firefox 43
Tracking Status
firefox43 --- fixed

People

(Reporter: vivek, Assigned: vivek, Mentored)

References

Details

Attachments

(1 file)

This is a follow bug that will support both per project and per build variant unit test as mentioned here 

https://bugzilla.mozilla.org/show_bug.cgi?id=1182193#c24
Bug 1204565 - Selectively enable unit test based on build variant r?nalexander

Project specific test filtering is automagically handled by gradle task graph
Attachment #8660957 - Flags: review?(nalexander)
Comment on attachment 8660957 [details]
MozReview Request: Bug 1204565 - Selectively enable unit test based on build variant r?nalexander

https://reviewboard.mozilla.org/r/19231/#review17571

::: mobile/android/gradle/build.gradle:72
(Diff revision 1)
> -            task.enabled = gradle.startParameter.taskNames.contains('test')
> +            task.enabled = startCommand.matches(pattern)

`contains` was nicer.  Join and test is not so nice.  How about using http://docs.groovy-lang.org/latest/html/api/org/codehaus/groovy/runtime/DefaultGroovyMethods.html#any%28java.lang.Iterable,%20groovy.lang.Closure%29

Something like
```
gradle.startParameter.taskNames.any { taskName ->
    taskName.matches(REGEXP)
}
```
should do the trick.
Attachment #8660957 - Flags: review?(nalexander)
Comment on attachment 8660957 [details]
MozReview Request: Bug 1204565 - Selectively enable unit test based on build variant r?nalexander

Bug 1204565 - Selectively enable unit test based on build variant r?nalexander

Project specific test filtering is automagically handled by gradle task graph
Attachment #8660957 - Flags: review?(nalexander)
Comment on attachment 8660957 [details]
MozReview Request: Bug 1204565 - Selectively enable unit test based on build variant r?nalexander

https://reviewboard.mozilla.org/r/19231/#review17585

::: mobile/android/gradle/build.gradle:74
(Diff revision 2)
> -        if (task.name.startsWith('test') && task.name.endsWith('UnitTest')) {
> +        if (task.name.matches(pattern)) {

Doesn't this check twice?
Attachment #8660957 - Flags: review?(nalexander)
Agreed with Nick over irc that current logic is correct.
The relevant irc conversation follows:

<vivek> About the check, we want to enable/disable only test task based on start command
<vivek> right?
<nalexander> Yes.  But you check the name during the taskGraph scan, and then again in the enable block.
<nalexander> Just set enable based on the name; or set enable to always consider the name.
<nalexander> No need to check twice.
<vivek> I'm confused. StartParameter.taskNames gives you what you enter in commandline. And TaskGraph.beforeTask gives all the dependent task. They are different things right. Correct me if I'm wrong
<nalexander> No, I think I'm wrong.  Let me think.
<nalexander> Ah!  I was confused.  So you're filtering the TaskGraph based on name, and then in enabled, you're deciding based on the StartParameter task names.
<vivek> Yes.
<vivek> So unless you specify test or a variant of it in commandline all test tasks are disabled
<nalexander> Yeah, I see now.  A few things threw me off, especially isTestTask not being itself a function.  But r+.  Flip the flag in BZ, land it DONTBUILD NPOTB.
<nalexander> (By which I mean, add a line, immediately below the main commit line, with DONTBUILD NPOTB.)
<nalexander> That just prevents automation from running builds and tests for it, which don't do anything.
<nalexander> Thanks for clarifying.
<vivek> should I rename isTestTask to something more clear. Please help here if needed
<vivek> :)
<nalexander> startTasksIncludeTest or something?
<nalexander> I don't really care.  It's clear when you think harder than I did :)
<vivek> ok, I'll change that, so that it is clear.
<nalexander> Sounds good.
https://hg.mozilla.org/integration/fx-team/rev/ad6dedfbd71c0076742456237c8bf78836a7e7d4
Bug 1204565 - Selectively enable unit test based on build variant r=nalexander
https://hg.mozilla.org/mozilla-central/rev/ad6dedfbd71c
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 43
Product: Android Background Services → Firefox for Android
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: