summaryrefslogtreecommitdiffstats
path: root/build/android
diff options
context:
space:
mode:
authorjbudorick@chromium.org <jbudorick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-21 23:35:10 +0000
committerjbudorick@chromium.org <jbudorick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-02-21 23:35:10 +0000
commit98cdac1048bbac41ebf2edc4aa72611c35d12f6c (patch)
tree4190644de0011880eb49a931b7ee40a4a8e323bf /build/android
parent7fdaa0d13cf04671247c0bb1187621a0ce9ab4e0 (diff)
downloadchromium_src-98cdac1048bbac41ebf2edc4aa72611c35d12f6c.zip
chromium_src-98cdac1048bbac41ebf2edc4aa72611c35d12f6c.tar.gz
chromium_src-98cdac1048bbac41ebf2edc4aa72611c35d12f6c.tar.bz2
Convert to gtest-style filtering in instrumentation tests.
BUG=280354 Review URL: https://codereview.chromium.org/144183004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252687 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'build/android')
-rw-r--r--build/android/pylib/host_driven/test_info_collection.py31
-rw-r--r--build/android/pylib/instrumentation/test_jar.py20
2 files changed, 30 insertions, 21 deletions
diff --git a/build/android/pylib/host_driven/test_info_collection.py b/build/android/pylib/host_driven/test_info_collection.py
index b0b76a9..150c4ae 100644
--- a/build/android/pylib/host_driven/test_info_collection.py
+++ b/build/android/pylib/host_driven/test_info_collection.py
@@ -6,9 +6,17 @@
import logging
import os
+import sys
from pylib.host_driven import tests_annotations
+from pylib import constants
+
+sys.path.insert(0,
+ os.path.join(constants.DIR_SOURCE_ROOT,
+ 'build', 'util', 'lib', 'common'))
+
+import unittest_util
class TestInfo(object):
"""An object containing and representing a test function, plus metadata."""
@@ -98,9 +106,13 @@ class TestInfoCollection(object):
excluded_tests = [t for t in available_tests if
self._AnnotationIncludesTest(t, exclude_annotations)]
available_tests = list(set(available_tests) - set(excluded_tests))
- available_tests = [t for t in available_tests if
- self._NameFilterIncludesTest(t, name_filter)]
+ if name_filter:
+ available_test_names = unittest_util.FilterTestNames(
+ [t.qualified_name for t in available_tests], name_filter)
+ available_tests = [
+ t for t in available_tests if
+ t.qualified_name in available_test_names]
return available_tests
@staticmethod
@@ -130,18 +142,3 @@ class TestInfoCollection(object):
return True
return False
- @staticmethod
- def _NameFilterIncludesTest(test_info, name_filter):
- """Checks whether a name filter matches a given test_info's method name.
-
- This is a case-sensitive, substring comparison: 'Foo' will match methods
- Foo.testBar and Bar.testFoo. 'foo' would not match either.
-
- Args:
- test_info: TestInfo object representing the test
- name_filter: substring to check for in the qualified name of the test
-
- Returns:
- True if no name filter supplied or it matches; False otherwise.
- """
- return not name_filter or name_filter in test_info.qualified_name
diff --git a/build/android/pylib/instrumentation/test_jar.py b/build/android/pylib/instrumentation/test_jar.py
index 9df90fc..53fd494 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