Index: build/android/pylib/instrumentation/test_jar.py |
diff --git a/build/android/pylib/instrumentation/test_jar.py b/build/android/pylib/instrumentation/test_jar.py |
index 9df90fcb7c0a785131bba4f6ce1190c9028367ff..53fd4948aad27caa9b2cc03c9d5d05a9f7140fa2 100644 |
--- a/build/android/pylib/instrumentation/test_jar.py |
+++ b/build/android/pylib/instrumentation/test_jar.py |
@@ -10,10 +10,16 @@ import logging |
import os |
import pickle |
import re |
+import sys |
from pylib import cmd_helper |
from pylib import constants |
+sys.path.insert(0, |
+ os.path.join(constants.DIR_SOURCE_ROOT, |
+ 'build', 'util', 'lib', 'common')) |
+ |
+import unittest_util |
# If you change the cached output of proguard, increment this number |
PICKLE_FORMAT_VERSION = 1 |
@@ -177,7 +183,7 @@ class TestJar(object): |
return sorted(tests_missing_annotations) |
def GetAllMatchingTests(self, annotation_filter_list, |
- exclude_annotation_list, test_filter): |
+ exclude_annotation_list, test_filter): |
"""Get a list of tests matching any of the annotations and the filter. |
Args: |
@@ -210,9 +216,15 @@ class TestJar(object): |
tests = [] |
if test_filter: |
# |available_tests| are in adb instrument format: package.path.class#test. |
- filter_without_hash = test_filter.replace('#', '.') |
- tests = [t for t in available_tests |
- if filter_without_hash in t.replace('#', '.')] |
+ |
+ # Maps a 'class.test' name to each 'package.path.class#test' name. |
+ sanitized_test_names = dict([ |
+ (t.split('.')[-1].replace('#', '.'), t) for t in available_tests]) |
+ # Filters 'class.test' names and populates |tests| with the corresponding |
+ # 'package.path.class#test' names. |
+ tests = [ |
+ sanitized_test_names[t] for t in unittest_util.FilterTestNames( |
+ sanitized_test_names.keys(), test_filter.replace('#', '.'))] |
else: |
tests = available_tests |