Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2750)

Unified Diff: build/util/lib/common/unittest_util.py

Issue 14882007: Android: support glob-style gtest filters with content browser tests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use DIR_SOURCE_ROOT. Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/util/lib/common/__init__.py ('k') | build/util/lib/common/util.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/util/lib/common/unittest_util.py
diff --git a/chrome/test/pylib/common/unittest_util.py b/build/util/lib/common/unittest_util.py
similarity index 84%
rename from chrome/test/pylib/common/unittest_util.py
rename to build/util/lib/common/unittest_util.py
index 9de980515bc599c52689b6c880747437d15e5b7f..ba17ea2b2599d5d44e32eec5ce9c45acb12bb8a7 100644
--- a/chrome/test/pylib/common/unittest_util.py
+++ b/build/util/lib/common/unittest_util.py
@@ -101,10 +101,32 @@ def FilterTestSuite(suite, gtest_filter):
def FilterTests(all_tests, gtest_filter):
- """Returns a filtered list of tests based on the given gtest filter.
+ """Filter a list of tests based on the given gtest filter.
+
+ Args:
+ all_tests: List of tests (unittest.TestSuite)
+ gtest_filter: Filter to apply.
+
+ Returns:
+ Filtered subset of the given list of tests.
+ """
+ test_names = [GetTestName(test) for test in all_tests]
+ filtered_names = FilterTestNames(test_names, gtest_filter)
+ return [test for test in all_tests if GetTestName(test) in filtered_names]
+
+
+def FilterTestNames(all_tests, gtest_filter):
+ """Filter a list of test names based on the given gtest filter.
See http://code.google.com/p/googletest/wiki/AdvancedGuide
for gtest_filter specification.
+
+ Args:
+ all_tests: List of test names.
+ gtest_filter: Filter to apply.
+
+ Returns:
+ Filtered subset of the given list of test names.
"""
pattern_groups = gtest_filter.split('-')
positive_patterns = pattern_groups[0].split(':')
@@ -114,16 +136,15 @@ def FilterTests(all_tests, gtest_filter):
tests = []
for test in all_tests:
- test_name = GetTestName(test)
# Test name must by matched by one positive pattern.
for pattern in positive_patterns:
- if fnmatch.fnmatch(test_name, pattern):
+ if fnmatch.fnmatch(test, pattern):
break
else:
continue
# Test name must not be matched by any negative patterns.
for pattern in negative_patterns or []:
- if fnmatch.fnmatch(test_name, pattern):
+ if fnmatch.fnmatch(test, pattern):
break
else:
tests += [test]
« no previous file with comments | « build/util/lib/common/__init__.py ('k') | build/util/lib/common/util.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698