From 6373021e54145b0ee95c60c85a6e2c523066cb06 Mon Sep 17 00:00:00 2001 From: vivek Date: Tue, 15 Sep 2015 00:55:49 +0300 Subject: [PATCH] Bug 1204565 - Selectively enable unit test based on build variant r=nalexander DONTBUILD NPOTB Project specific test filtering is automagically handled by gradle task graph --HG-- extra : commitid : 2vx7QzGNVUI extra : rebase_source : 63254386dca7f0aa5c6a5894f7915b2ed50dd65e --- mobile/android/gradle/build.gradle | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mobile/android/gradle/build.gradle b/mobile/android/gradle/build.gradle index f89aeb88fee3..b5e8d69aa5db 100644 --- a/mobile/android/gradle/build.gradle +++ b/mobile/android/gradle/build.gradle @@ -1,3 +1,5 @@ +import java.util.regex.Pattern + allprojects { // Expose the per-object-directory configuration to all projects. ext { @@ -62,10 +64,15 @@ task generateCodeAndResources(type:Exec) { // Skip unit test for all build variants, unless if it was specifically requested by user. // The enabled property for the unit test tasks is reset based on the command line task names just before the task execution. // I bet there is a easier/cleaner way to do this, but this gets the job done for now. +Pattern pattern = Pattern.compile('.*test(.+UnitTest)?.*') +boolean startTasksIncludeTest = gradle.startParameter.taskNames.any { + taskName -> + taskName.matches(pattern) +} gradle.taskGraph.beforeTask { Task task -> - if (task.name.startsWith('test') && task.name.endsWith('UnitTest')) { - task.enabled = gradle.startParameter.taskNames.contains('test') + if (task.name.matches(pattern)) { + task.enabled = startTasksIncludeTest } }