Chromium Code Reviews| Index: build/android/pylib/local/device/local_device_gtest_run.py |
| diff --git a/build/android/pylib/local/device/local_device_gtest_run.py b/build/android/pylib/local/device/local_device_gtest_run.py |
| index 0f360d4a9e943045c946f68689f98788fd2966e9..c0903885d1f21098fcaceeb615e275be59c43b28 100644 |
| --- a/build/android/pylib/local/device/local_device_gtest_run.py |
| +++ b/build/android/pylib/local/device/local_device_gtest_run.py |
| @@ -52,6 +52,32 @@ def PullAppFilesImpl(device, package, files, directory): |
| break |
| device.PullFile(device_file, host_file) |
| + |
| +def _ExtractTestsFromFilter(gtest_filter): |
| + """Returns the list of tests specified by the given filter. |
| + |
| + Returns: |
| + None if the device should be queried for the test list instead. |
| + """ |
| + # Empty means all tests, - means exclude filter. |
| + if not gtest_filter or '-' in gtest_filter: |
| + return None |
| + |
| + patterns = gtest_filter.split(':') |
| + # For a single pattern, allow it even if it has a wildcard so long as the |
| + # wildcard comes at the end and there is at least one . to prove the scope is |
| + # not too large. |
| + # This heuristic is not necessarily faster, but normally is. |
| + if len(patterns) == 1 and patterns[0].endswith('*'): |
| + no_suffix = patterns[0].rstrip('*') |
| + if '*' not in no_suffix and '.' in no_suffix: |
| + return patterns |
| + |
| + if '*' in gtest_filter: |
| + return None |
| + return patterns |
| + |
| + |
| class _ApkDelegate(object): |
| def __init__(self, test_instance): |
| self._activity = test_instance.activity |
| @@ -229,8 +255,18 @@ class LocalDeviceGtestRun(local_device_test_run.LocalDeviceTestRun): |
| tests = self._test_instance.FilterTests(tests) |
| return tests |
| - test_lists = self._env.parallel_devices.pMap(list_tests).pGet(None) |
| - tests = list(sorted(set().union(*[set(tl) for tl in test_lists if tl]))) |
| + # When the list of tests to run is given via command-line, skip querying the |
|
jbudorick
2015/10/13 17:17:48
As written, this is structured in a way that impli
agrieve
2015/10/13 20:13:27
Done (and updated comments to be a bit more specia
|
| + # device (which takes ~3 seconds). |
| + gtest_filter = self._test_instance.gtest_filter |
| + tests = _ExtractTestsFromFilter(gtest_filter) |
| + |
| + # Even when there's only one device, it still makes sense to retrieve the |
| + # test list so that tests can be split up and run in batches rather than all |
| + # at once (since test output is not streamed). |
| + if not tests: |
| + # Query all devices in case one fails. |
| + test_lists = self._env.parallel_devices.pMap(list_tests).pGet(None) |
| + tests = list(sorted(set().union(*[set(tl) for tl in test_lists if tl]))) |
| return tests |
| #override |