OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 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 """Runs the Python tests (relies on using the Java test runner).""" | 5 """Runs the Python tests (relies on using the Java test runner).""" |
6 | 6 |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 import types | 10 import types |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 test_files_copier = run_java_tests.TestRunner(options, device_id, | 88 test_files_copier = run_java_tests.TestRunner(options, device_id, |
89 None, False, 0, apks, []) | 89 None, False, 0, apks, []) |
90 test_files_copier.CopyTestFilesOnce() | 90 test_files_copier.CopyTestFilesOnce() |
91 | 91 |
92 # Actually run the tests. | 92 # Actually run the tests. |
93 if len(attached_devices) > 1 and options.wait_for_debugger: | 93 if len(attached_devices) > 1 and options.wait_for_debugger: |
94 logging.warning('Debugger can not be sharded, ' | 94 logging.warning('Debugger can not be sharded, ' |
95 'using first available device') | 95 'using first available device') |
96 attached_devices = attached_devices[:1] | 96 attached_devices = attached_devices[:1] |
97 logging.debug('Running Python tests') | 97 logging.debug('Running Python tests') |
98 sharder = PythonTestSharder(attached_devices, options.shard_retries, | 98 sharder = PythonTestSharder(attached_devices, available_tests, options) |
99 available_tests) | |
100 test_results = sharder.RunShardedTests() | 99 test_results = sharder.RunShardedTests() |
101 | 100 |
102 return test_results | 101 return test_results |
103 | 102 |
104 | 103 |
105 def _RunPythonTests(tests_to_run, device_id): | |
106 """Runs a list of Python tests serially on one device and returns results. | |
107 | |
108 Args: | |
109 tests_to_run: a list of objects inheriting from PythonTestBase. | |
110 device_id: ID of the device to run tests on. | |
111 | |
112 Returns: | |
113 A list of test results, aggregated across all the tests run. | |
114 """ | |
115 # This is a list of TestResults objects. | |
116 results = [CallPythonTest(t, device_id, 0) for t in tests_to_run] | |
117 # Merge the list of TestResults into one TestResults. | |
118 return TestResults.FromTestResults(results) | |
119 | |
120 | |
121 def _GetTestModules(python_test_root, is_official_build): | 104 def _GetTestModules(python_test_root, is_official_build): |
122 """Retrieve a sorted list of pythonDrivenTests. | 105 """Retrieve a sorted list of pythonDrivenTests. |
123 | 106 |
124 Walks the location of pythonDrivenTests, imports them, and provides the list | 107 Walks the location of pythonDrivenTests, imports them, and provides the list |
125 of imported modules to the caller. | 108 of imported modules to the caller. |
126 | 109 |
127 Args: | 110 Args: |
128 python_test_root: the path to walk, looking for pythonDrivenTests | 111 python_test_root: the path to walk, looking for pythonDrivenTests |
129 is_official_build: whether to run only those tests marked 'official' | 112 is_official_build: whether to run only those tests marked 'official' |
130 | 113 |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 Returns: | 198 Returns: |
216 List of test case objects for all available test methods. | 199 List of test case objects for all available test methods. |
217 """ | 200 """ |
218 if not test_root: | 201 if not test_root: |
219 return [] | 202 return [] |
220 all_tests = [] | 203 all_tests = [] |
221 test_module_list = _GetTestModules(test_root, is_official_build) | 204 test_module_list = _GetTestModules(test_root, is_official_build) |
222 for module in test_module_list: | 205 for module in test_module_list: |
223 all_tests.extend(_GetTestClassesFromModule(module)) | 206 all_tests.extend(_GetTestClassesFromModule(module)) |
224 return all_tests | 207 return all_tests |
OLD | NEW |