| 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.base import base_test_result | 13 from pylib.base import base_test_result |
| 14 from pylib.instrumentation import test_options |
| 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 from pylib.utils import report_results |
| 17 | 18 |
| 18 import python_test_base | 19 import python_test_base |
| 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): |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 return (base_test_result.TestRunResults(), 0) | 81 return (base_test_result.TestRunResults(), 0) |
| 81 | 82 |
| 82 test_names = [t.qualified_name for t in available_tests] | 83 test_names = [t.qualified_name for t in available_tests] |
| 83 logging.debug('Final list of tests to run: ' + str(test_names)) | 84 logging.debug('Final list of tests to run: ' + str(test_names)) |
| 84 | 85 |
| 85 # Copy files to each device before running any tests. | 86 # Copy files to each device before running any tests. |
| 86 for device_id in attached_devices: | 87 for device_id in attached_devices: |
| 87 logging.debug('Pushing files to device %s', device_id) | 88 logging.debug('Pushing files to device %s', device_id) |
| 88 test_pkg = test_package.TestPackage(options.test_apk_path, | 89 test_pkg = test_package.TestPackage(options.test_apk_path, |
| 89 options.test_apk_jar_path) | 90 options.test_apk_jar_path) |
| 90 test_files_copier = test_runner.TestRunner( | 91 instrumentation_options = test_options.InstrumentationOptions( |
| 91 options.build_type, options.test_data, options.save_perf_json, | 92 options.build_type, |
| 92 options.screenshot_failures, options.tool, options.wait_for_debugger, | 93 options.tool, |
| 93 options.disable_assertions, options.push_deps, | 94 options.cleanup_test_files, |
| 94 options.cleanup_test_files, device_id, 0, test_pkg, []) | 95 options.push_deps, |
| 96 options.annotations, |
| 97 options.exclude_annotations, |
| 98 options.test_filter, |
| 99 options.test_data, |
| 100 options.save_perf_json, |
| 101 options.screenshot_failures, |
| 102 options.disable_assertions, |
| 103 options.wait_for_debugger, |
| 104 options.test_apk, |
| 105 options.test_apk_path, |
| 106 options.test_apk_jar_path) |
| 107 test_files_copier = test_runner.TestRunner(instrumentation_options, |
| 108 device_id, 0, test_pkg, []) |
| 95 test_files_copier.InstallTestPackage() | 109 test_files_copier.InstallTestPackage() |
| 96 if options.push_deps: | 110 if options.push_deps: |
| 97 logging.info('Pushing data deps to device.') | 111 logging.info('Pushing data deps to device.') |
| 98 test_files_copier.PushDataDeps() | 112 test_files_copier.PushDataDeps() |
| 99 else: | 113 else: |
| 100 logging.warning('Skipping pushing data deps to device.') | 114 logging.warning('Skipping pushing data deps to device.') |
| 101 | 115 |
| 102 # Actually run the tests. | 116 # Actually run the tests. |
| 103 if len(attached_devices) > 1 and options.wait_for_debugger: | 117 if len(attached_devices) > 1 and options.wait_for_debugger: |
| 104 logging.warning('Debugger can not be sharded, ' | 118 logging.warning('Debugger can not be sharded, ' |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 Returns: | 225 Returns: |
| 212 List of test case objects for all available test methods. | 226 List of test case objects for all available test methods. |
| 213 """ | 227 """ |
| 214 if not test_root: | 228 if not test_root: |
| 215 return [] | 229 return [] |
| 216 all_tests = [] | 230 all_tests = [] |
| 217 test_module_list = _GetTestModules(test_root, is_official_build) | 231 test_module_list = _GetTestModules(test_root, is_official_build) |
| 218 for module in test_module_list: | 232 for module in test_module_list: |
| 219 all_tests.extend(_GetTestClassesFromModule(module)) | 233 all_tests.extend(_GetTestClassesFromModule(module)) |
| 220 return all_tests | 234 return all_tests |
| OLD | NEW |