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 |
11 | 11 |
12 from pylib import android_commands | 12 from pylib import android_commands |
13 from pylib import constants | |
14 from pylib.base import base_test_result | 13 from pylib.base import base_test_result |
15 from pylib.instrumentation import test_package | 14 from pylib.instrumentation import test_package |
16 from pylib.instrumentation import test_runner | 15 from pylib.instrumentation import test_runner |
| 16 from pylib.utils import report_results |
17 | 17 |
18 import python_test_base | 18 import python_test_base |
19 from python_test_caller import CallPythonTest | |
20 from python_test_sharder import PythonTestSharder | 19 from python_test_sharder import PythonTestSharder |
21 from test_info_collection import TestInfoCollection | 20 from test_info_collection import TestInfoCollection |
22 | 21 |
23 | 22 |
24 def _GetPythonFiles(root, files): | 23 def _GetPythonFiles(root, files): |
25 """Returns all files from |files| that end in 'Test.py'. | 24 """Returns all files from |files| that end in 'Test.py'. |
26 | 25 |
27 Args: | 26 Args: |
28 root: A directory name with python files. | 27 root: A directory name with python files. |
29 files: A list of file names. | 28 files: A list of file names. |
(...skipping 19 matching lines...) Expand all Loading... |
49 | 48 |
50 | 49 |
51 def DispatchPythonTests(options): | 50 def DispatchPythonTests(options): |
52 """Dispatches the Python tests. If there are multiple devices, use sharding. | 51 """Dispatches the Python tests. If there are multiple devices, use sharding. |
53 | 52 |
54 Args: | 53 Args: |
55 options: command line options. | 54 options: command line options. |
56 | 55 |
57 Returns: | 56 Returns: |
58 A list of test results. | 57 A list of test results. |
| 58 |
| 59 Raises: |
| 60 Exception: If there are no attached devices. |
59 """ | 61 """ |
60 | 62 |
61 attached_devices = android_commands.GetAttachedDevices() | 63 attached_devices = android_commands.GetAttachedDevices() |
62 if not attached_devices: | 64 if not attached_devices: |
63 raise Exception('You have no devices attached or visible!') | 65 raise Exception('You have no devices attached or visible!') |
64 if options.device: | 66 if options.test_device: |
65 attached_devices = [options.device] | 67 attached_devices = [options.test_device] |
66 | 68 |
67 test_collection = TestInfoCollection() | 69 test_collection = TestInfoCollection() |
68 all_tests = _GetAllTests(options.python_test_root, options.official_build) | 70 all_tests = _GetAllTests(options.python_test_root, options.official_build) |
69 test_collection.AddTests(all_tests) | 71 test_collection.AddTests(all_tests) |
70 test_names = [t.qualified_name for t in all_tests] | 72 test_names = [t.qualified_name for t in all_tests] |
71 logging.debug('All available tests: ' + str(test_names)) | 73 logging.debug('All available tests: ' + str(test_names)) |
72 | 74 |
73 available_tests = test_collection.GetAvailableTests( | 75 available_tests = test_collection.GetAvailableTests( |
74 options.annotations, options.exclude_annotations, options.test_filter) | 76 options.annotations, options.exclude_annotations, options.test_filter) |
75 | 77 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 Returns: | 205 Returns: |
204 List of test case objects for all available test methods. | 206 List of test case objects for all available test methods. |
205 """ | 207 """ |
206 if not test_root: | 208 if not test_root: |
207 return [] | 209 return [] |
208 all_tests = [] | 210 all_tests = [] |
209 test_module_list = _GetTestModules(test_root, is_official_build) | 211 test_module_list = _GetTestModules(test_root, is_official_build) |
210 for module in test_module_list: | 212 for module in test_module_list: |
211 all_tests.extend(_GetTestClassesFromModule(module)) | 213 all_tests.extend(_GetTestClassesFromModule(module)) |
212 return all_tests | 214 return all_tests |
OLD | NEW |