From 8fef05f2c11e6f9f90e8c139bb7af42581941f4f Mon Sep 17 00:00:00 2001 From: Allen Hair Date: Mon, 29 Aug 2016 12:21:02 -0700 Subject: [PATCH] Fine tune code coverage filters for SystemUI tests. Bug: 28269038 Change-Id: Iece993a76b39873170c4ae0b2d1cd2dd5445e3c2 --- packages/SystemUI/tests/Android.mk | 35 +++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/packages/SystemUI/tests/Android.mk b/packages/SystemUI/tests/Android.mk index 188f8bf9b7f60..d122cccfb74c3 100644 --- a/packages/SystemUI/tests/Android.mk +++ b/packages/SystemUI/tests/Android.mk @@ -58,9 +58,42 @@ LOCAL_STATIC_JAVA_LIBRARIES := \ # UI it doesn't own. This is necessary to allow screenshots to be taken LOCAL_CERTIFICATE := platform +# Provide jack a list of classes to exclude from code coverage. +# This is needed because the SystemUITests compile SystemUI source directly, rather than using +# LOCAL_INSTRUMENTATION_FOR := SystemUI. +# +# We want to exclude the test classes from code coverage measurements, but they share the same +# package as the rest of SystemUI so they can't be easily filtered by package name. +# +# Generate a comma separated list of patterns based on the test source files under src/ +# SystemUI classes are in ../src/ so they won't be excluded. +# Example: +# Input files: src/com/android/systemui/Test.java src/com/android/systemui/AnotherTest.java +# Generated exclude list: com.android.systemui.Test*,com.android.systemui.AnotherTest* + +# Filter all src files under src/ to just java files +local_java_files := $(filter %.java,$(call all-java-files-under, src)) +# Transform java file names into full class names. +# This only works if the class name matches the file name and the directory structure +# matches the package. +local_classes := $(subst /,.,$(patsubst src/%.java,%,$(local_java_files))) +local_comma := , +local_empty := +local_space := $(local_empty) $(local_empty) +# Convert class name list to jacoco exclude list +# This appends a * to all classes and replace the space separators with commas. +jacoco_exclude := $(subst $(space),$(comma),$(patsubst %,%*,$(local_classes))) + LOCAL_JACK_COVERAGE_INCLUDE_FILTER := com.android.systemui.* -LOCAL_JACK_COVERAGE_EXCLUDE_FILTER := com.android.systemui.tests.* +LOCAL_JACK_COVERAGE_EXCLUDE_FILTER := com.android.systemui.tests.*,$(jacoco_exclude) include frameworks/base/packages/SettingsLib/common.mk include $(BUILD_PACKAGE) + +# Reset variables +local_java_files := +local_classes := +local_comma := +local_space := +jacoco_exclude :=