OLD | NEW |
1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Generates test runner factory and tests for GTests.""" | 5 """Generates test runner factory and tests for GTests.""" |
6 # pylint: disable=W0212 | 6 # pylint: disable=W0212 |
7 | 7 |
8 import logging | 8 import logging |
9 import os | 9 import os |
10 import sys | 10 import sys |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 """Get a list of tests. | 136 """Get a list of tests. |
137 | 137 |
138 Args: | 138 Args: |
139 test_options: A GTestOptions object. | 139 test_options: A GTestOptions object. |
140 test_package: A TestPackageApk object. | 140 test_package: A TestPackageApk object. |
141 devices: A list of attached devices. | 141 devices: A list of attached devices. |
142 | 142 |
143 Returns: | 143 Returns: |
144 A list of all the tests in the test suite. | 144 A list of all the tests in the test suite. |
145 """ | 145 """ |
| 146 class TestListResult(base_test_result.BaseTestResult): |
| 147 def __init__(self): |
| 148 super(TestListResult, self).__init__( |
| 149 'gtest_list_tests', base_test_result.ResultType.PASS) |
| 150 self.test_list = [] |
| 151 |
146 def TestListerRunnerFactory(device, _shard_index): | 152 def TestListerRunnerFactory(device, _shard_index): |
147 class TestListerRunner(test_runner.TestRunner): | 153 class TestListerRunner(test_runner.TestRunner): |
148 def RunTest(self, _test): | 154 def RunTest(self, _test): |
149 result = base_test_result.BaseTestResult( | 155 result = TestListResult() |
150 'gtest_list_tests', base_test_result.ResultType.PASS) | |
151 self.test_package.Install(self.device) | 156 self.test_package.Install(self.device) |
152 result.test_list = self.test_package.GetAllTests(self.device) | 157 result.test_list = self.test_package.GetAllTests(self.device) |
153 results = base_test_result.TestRunResults() | 158 results = base_test_result.TestRunResults() |
154 results.AddResult(result) | 159 results.AddResult(result) |
155 return results, None | 160 return results, None |
156 return TestListerRunner(test_options, device, test_package) | 161 return TestListerRunner(test_options, device, test_package) |
157 | 162 |
158 results, _no_retry = test_dispatcher.RunTests( | 163 results, _no_retry = test_dispatcher.RunTests( |
159 ['gtest_list_tests'], TestListerRunnerFactory, devices) | 164 ['gtest_list_tests'], TestListerRunnerFactory, devices) |
160 tests = [] | 165 tests = [] |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 if test_options.gtest_filter: | 281 if test_options.gtest_filter: |
277 tests = unittest_util.FilterTestNames(tests, test_options.gtest_filter) | 282 tests = unittest_util.FilterTestNames(tests, test_options.gtest_filter) |
278 | 283 |
279 # Coalesce unit tests into a single test per device | 284 # Coalesce unit tests into a single test per device |
280 if test_options.suite_name != 'content_browsertests': | 285 if test_options.suite_name != 'content_browsertests': |
281 num_devices = len(devices) | 286 num_devices = len(devices) |
282 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] | 287 tests = [':'.join(tests[i::num_devices]) for i in xrange(num_devices)] |
283 tests = [t for t in tests if t] | 288 tests = [t for t in tests if t] |
284 | 289 |
285 return (TestRunnerFactory, tests) | 290 return (TestRunnerFactory, tests) |
OLD | NEW |