Chromium Code Reviews| Index: build/android/pylib/browsertests/dispatch.py |
| diff --git a/build/android/pylib/browsertests/dispatch.py b/build/android/pylib/browsertests/dispatch.py |
| index c598d6447bd88ef7fe621c4fb22f2b1a21e6404d..fbeb3970e67f36b8cb0f69e7719803f1f655d19c 100644 |
| --- a/build/android/pylib/browsertests/dispatch.py |
| +++ b/build/android/pylib/browsertests/dispatch.py |
| @@ -2,6 +2,7 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| +import fnmatch |
| import logging |
| import os |
| @@ -53,12 +54,12 @@ def Dispatch(options): |
| constants.BROWSERTEST_TEST_ACTIVITY_NAME, |
| constants.BROWSERTEST_COMMAND_LINE_FILE) |
| - # Get tests and split them up based on the number of devices. |
| + # Get tests and split them up based on the number of devices. |
| + all_enabled = gtest_dispatch.GetAllEnabledTests(RunnerFactory, |
| + attached_devices) |
| if options.gtest_filter: |
| - all_tests = [t for t in options.gtest_filter.split(':') if t] |
| + all_tests = _ApplyGtestFilter(all_enabled, options.gtest_filter) |
| else: |
| - all_enabled = gtest_dispatch.GetAllEnabledTests(RunnerFactory, |
| - attached_devices) |
| all_tests = _FilterTests(all_enabled) |
| # Run tests. |
| @@ -82,6 +83,24 @@ def _FilterTests(all_enabled_tests): |
| """Filters out tests and fixtures starting with PRE_ and MANUAL_.""" |
| return [t for t in all_enabled_tests if _ShouldRunOnBot(t)] |
| +def _ApplyGtestFilter(all_enabled_tests, gtest_filter): |
| + """Computes the result of applying the given gtest filter to the list of |
|
bulach
2013/05/13 13:19:37
nit: one liner doctstring as title, then \n then a
Sami
2013/05/13 14:58:10
Done.
|
| + available tests. |
| + """ |
| + filter_patterns = [t for t in gtest_filter.split(':') if t] |
| + # Any test that matches a positive patterns but does not match any negative |
| + # pattern should be returned. |
| + result = set() |
| + for pattern in filter_patterns: |
| + if not pattern.startswith('-'): |
| + result.update([t for t in all_enabled_tests |
| + if fnmatch.fnmatch(t, pattern)]) |
| + for pattern in filter_patterns: |
| + if pattern.startswith('-'): |
| + result.difference_update([t for t in all_tests |
| + if fnmatch.fnmatch(t, pattern[1:])]) |
| + return list(result) |
| + |
| def _ShouldRunOnBot(test): |
| fixture, case = test.split('.', 1) |
| if _StartsWith(fixture, case, "PRE_"): |