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