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 9369959ed2af3e17900d073976d8106356a15d50..94c80240abfebcdff7c23f981bf84b621201235c 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): |
|
jbudorick
2015/10/08 15:01:46
It's hard for me to describe why, but this whole m
agrieve
2015/10/08 15:59:47
Yeah, I had at first just cached the test list lik
|
| + """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,17 @@ class LocalDeviceGtestRun(local_device_test_run.LocalDeviceTestRun): |
| tests = self._test_instance.FilterTests(tests) |
| return tests |
| - # Result should be the same for all devices, so just use the first one. |
| - return list_tests(self._env.devices[0]) |
| + # When there's only one device, it still makes sense to retrieve the test |
| + # list since test output is not retrieve until after the test completes. |
|
jbudorick
2015/10/08 15:01:46
Why do you say that it still makes sense to retrie
agrieve
2015/10/08 15:59:46
Clarified (but not 100% sure it's even the case, s
|
| + gtest_filter = self._test_instance.gtest_filter |
| + # But when running only a single test, skip querying the device (which |
| + # takes ~3 seconds). |
| + tests = _ExtractTestsFromFilter(gtest_filter) |
| + |
| + if not tests: |
| + # Result should be the same for all devices, so just use the first one. |
| + tests = list_tests(self._env.devices[0]) |
| + return tests |
| #override |
| def _RunTest(self, device, test): |