Chromium Code Reviews| Index: build/android/pylib/gtest/setup.py |
| diff --git a/build/android/pylib/gtest/setup.py b/build/android/pylib/gtest/setup.py |
| index e62b64811aaee30b04a749f73d98aa684f9b3bba..53186ba063018562ad14fe8210b941265209e8b8 100644 |
| --- a/build/android/pylib/gtest/setup.py |
| +++ b/build/android/pylib/gtest/setup.py |
| @@ -12,10 +12,11 @@ import os |
| import shutil |
| import sys |
| -from pylib import android_commands |
| from pylib import cmd_helper |
| from pylib import constants |
| +from pylib.base import base_test_result |
| +from pylib.base import test_dispatcher |
| from pylib.gtest import test_package_apk |
| from pylib.gtest import test_package_exe |
| from pylib.gtest import test_runner |
| @@ -204,26 +205,34 @@ def _GetDisabledTestsFilterFromFile(suite_name): |
| return disabled_filter |
| -def _GetTestsFromDevice(runner_factory, devices): |
| - """Get a list of tests from a device. |
| +def _GetTests(test_options, test_package, devices): |
| + """Get a list of tests. |
| Args: |
| - runner_factory: Callable that takes device and shard_index and returns |
| - a TestRunner. |
| - devices: A list of device ids. |
| + test_options: A GTestOptions object. |
| + test_package: A TestPackageApk object. |
| + devices: A list of attached devices. |
| Returns: |
| - All the tests in the test suite. |
| + A list of all the tests in the test suite. |
| """ |
| - for device in devices: |
| - try: |
| - logging.info('Obtaining tests from %s', device) |
| - return runner_factory(device, 0).GetAllTests() |
| - except (android_commands.errors.WaitForResponseTimedOutError, |
| - android_commands.errors.DeviceUnresponsiveError), e: |
| - logging.warning('Failed obtaining test list from %s with exception: %s', |
| - device, e) |
| - raise Exception('Failed to obtain test list from devices.') |
| + def TestListerRunnerFactory(device, _shard_index): |
| + class TestListerRunner(test_runner.TestRunner): |
| + def RunTest(self, _test): |
| + result = base_test_result.BaseTestResult( |
| + 'ListTheTests', base_test_result.ResultType.PASS) |
|
craigdh
2014/04/03 21:58:06
Since this only applies to gtests, the resulting e
|
| + result.test_list = self.GetAllTests() |
|
craigdh
2014/04/03 21:58:06
just move the code from GetAllTests() inline here,
|
| + results = base_test_result.TestRunResults() |
| + results.AddResult(result) |
| + return results, None |
| + return TestListerRunner(test_options, device, test_package) |
| + |
| + results, _no_retry = test_dispatcher.RunTests( |
| + ['ListTheTests'], TestListerRunnerFactory, devices) |
| + tests = [] |
| + for r in results.GetAll(): |
| + tests.extend(r.test_list) |
| + return tests |
| def _FilterTestsUsingPrefixes(all_tests, pre=False, manual=False): |
| @@ -299,6 +308,8 @@ def Setup(test_options, devices): |
| _GenerateDepsDirUsingIsolate(test_options.suite_name) |
| + tests = _GetTests(test_options, test_package, devices) |
| + |
| # Constructs a new TestRunner with the current options. |
| def TestRunnerFactory(device, _shard_index): |
| return test_runner.TestRunner( |
| @@ -306,7 +317,6 @@ def Setup(test_options, devices): |
| device, |
| test_package) |
| - tests = _GetTestsFromDevice(TestRunnerFactory, devices) |
| if test_options.run_disabled: |
| test_options = test_options._replace( |
| test_arguments=('%s --gtest_also_run_disabled_tests' % |