Chromium Code Reviews| Index: build/android/pylib/host_driven/run_python_tests.py |
| diff --git a/build/android/pylib/host_driven/run_python_tests.py b/build/android/pylib/host_driven/run_python_tests.py |
| index bde75d242bed3748f80a4658f3b4e321da79f947..da09e79a463fa76e9da2b5ad0219a9a65db6a643 100644 |
| --- a/build/android/pylib/host_driven/run_python_tests.py |
| +++ b/build/android/pylib/host_driven/run_python_tests.py |
| @@ -12,8 +12,11 @@ import types |
| from pylib import android_commands |
| from pylib import constants |
| from pylib.base import base_test_result |
| -from pylib.instrumentation import test_package |
| -from pylib.instrumentation import test_runner |
| +from pylib.instrumentation import test_package as instrumentation_test_package |
| +from pylib.instrumentation import test_runner as instrumentation_test_runner |
| +from pylib.uiautomator import test_package as uiautomator_test_package |
| +from pylib.uiautomator import test_runner as uiautomator_test_runner |
| +from pylib.utils import report_results |
| import python_test_base |
| from python_test_caller import CallPythonTest |
| @@ -61,8 +64,8 @@ def DispatchPythonTests(options): |
| attached_devices = android_commands.GetAttachedDevices() |
| if not attached_devices: |
| raise Exception('You have no devices attached or visible!') |
| - if options.device: |
| - attached_devices = [options.device] |
| + if options.test_device: |
| + attached_devices = [options.test_device] |
|
frankf
2013/06/11 02:50:15
Why this name change?
gkanwar
2013/06/12 01:27:32
There were previously two settings: --device for i
|
| test_collection = TestInfoCollection() |
| all_tests = _GetAllTests(options.python_test_root, options.official_build) |
| @@ -83,11 +86,24 @@ def DispatchPythonTests(options): |
| # Copy files to each device before running any tests. |
| for device_id in attached_devices: |
| logging.debug('Pushing files to device %s', device_id) |
| - test_pkg = test_package.TestPackage(options.test_apk_path, |
| - options.test_apk_jar_path) |
| - test_files_copier = test_runner.TestRunner( |
| - options, device_id, 0, test_pkg, []) |
| - test_files_copier.PushDependencies() |
| + try: |
| + test_pkg = instrumentation_test_package.TestPackage(options.test_apk_path, |
|
frankf
2013/06/11 02:50:15
Hmm. Actually let's not touch host_driven tests as
gkanwar
2013/06/12 01:27:32
Done.
|
| + options.test_apk_jar_path) |
| + test_files_copier = instrumentation_test_runner.TestRunner( |
| + options, device_id, 0, test_pkg, []) |
| + test_files_copier.PushDependencies() |
| + except AttributeError as e: |
| + logging.debug('No test APK defined, we are not running ' |
| + 'non-UIAutomator instrumentation tests.') |
| + try: |
| + test_pkg = uiautomator_test_package.TestPackage(options.test_apk_path, |
| + options.test_apk_jar_path) |
| + test_files_copier = uiautomator_test_runner.TestRunner( |
| + options, device_id, 0, test_pkg, []) |
| + test_files_copier.PushDependencies() |
| + except AttributeError as e: |
| + logging.debug('No test JAR defined, we are not running ' |
| + 'UIAutomator instrumentation tests.') |
| # Actually run the tests. |
| if len(attached_devices) > 1 and options.wait_for_debugger: |
| @@ -101,6 +117,20 @@ def DispatchPythonTests(options): |
| return test_results |
| +def Dispatch(options): |
| + """Wraps DispatchPythonTests to log and return the number of failed tests.""" |
| + |
| + results = DispatchPythonTests(options) |
| + report_results.LogFull( |
| + results=results, |
| + test_type='HostDriven', |
| + test_package=os.path.basename(options.test_apk), |
| + annotation=options.annotations, |
| + build_type=options.build_type, |
| + flakiness_server=options.flakiness_dashboard_server) |
| + return len(results.GetNotPass()) |
| + |
| + |
| def _GetTestModules(python_test_root, is_official_build): |
| """Retrieve a sorted list of pythonDrivenTests. |