| Index: build/android/pylib/instrumentation/setup.py
|
| diff --git a/build/android/pylib/instrumentation/dispatch.py b/build/android/pylib/instrumentation/setup.py
|
| similarity index 25%
|
| rename from build/android/pylib/instrumentation/dispatch.py
|
| rename to build/android/pylib/instrumentation/setup.py
|
| index e4ca2805243c6edb7f02830ae28bd808256ef6df..3c35a3e404ee37a0ac0dc7c12975524fb365cc86 100644
|
| --- a/build/android/pylib/instrumentation/dispatch.py
|
| +++ b/build/android/pylib/instrumentation/setup.py
|
| @@ -2,7 +2,7 @@
|
| # Use of this source code is governed by a BSD-style license that can be
|
| # found in the LICENSE file.
|
|
|
| -"""Dispatches the instrumentation tests."""
|
| +"""Generates test runner factory and tests for instrumentation tests."""
|
|
|
| import logging
|
| import os
|
| @@ -10,53 +10,48 @@ import os
|
| from pylib import android_commands
|
| from pylib import constants
|
| from pylib.base import base_test_result
|
| -from pylib.base import shard
|
| from pylib.utils import report_results
|
|
|
| import test_package
|
| import test_runner
|
|
|
|
|
| -def Dispatch(options):
|
| - """Dispatches instrumentation tests onto connected device(s).
|
| -
|
| - If possible, this method will attempt to shard the tests to
|
| - all connected devices. Otherwise, dispatch and run tests on one device.
|
| +def Setup(test_apk_path, test_apk_jar_path, annotations, exclude_annotations,
|
| + test_filter, build_type, test_data, install_apk, save_perf_json,
|
| + screenshot_failures, tool, wait_for_debugger, disable_assertions,
|
| + push_deps, cleanup_test_files):
|
| + """Create and return the test runner factory and tests.
|
|
|
| Args:
|
| - options: Command line options.
|
| + test_apk_path: Path to the test apk file.
|
| + test_apk_jar_path: Path to the jar associated with the test apk.
|
| + annotations: Annotations for the tests.
|
| + exclude_annotations: Any annotations to exclude from running.
|
| + test_filter: Filter string for tests.
|
| + build_type: 'Release' or 'Debug'.
|
| + test_data: Location of the test data.
|
| + install_apk: Re-installs the apk if opted.
|
| + save_perf_json: Whether or not to save the JSON file from UI perf tests.
|
| + screenshot_failures: Take a screenshot for a test failure
|
| + tool: Name of the Valgrind tool.
|
| + wait_for_debugger: blocks until the debugger is connected.
|
| + disable_assertions: Whether to disable java assertions on the device.
|
| + push_deps: If True, push all dependencies to the device.
|
| + cleanup_test_files: Whether or not to cleanup test files on device.
|
|
|
| Returns:
|
| - A tuple of (base_test_result.TestRunResults object, exit code).
|
| -
|
| - Raises:
|
| - Exception: when there are no attached devices.
|
| + A tuple of (TestRunnerFactory, tests).
|
| """
|
| - test_pkg = test_package.TestPackage(options.test_apk_path,
|
| - options.test_apk_jar_path)
|
| - tests = test_pkg._GetAllMatchingTests(
|
| - options.annotations, options.exclude_annotations, options.test_filter)
|
| + test_pkg = test_package.TestPackage(test_apk_path, test_apk_jar_path)
|
| + tests = test_pkg._GetAllMatchingTests(annotations, exclude_annotations,
|
| + test_filter)
|
| if not tests:
|
| logging.error('No instrumentation tests to run with current args.')
|
| - return (base_test_result.TestRunResults(), constants.ERROR_EXIT_CODE)
|
| -
|
| - attached_devices = android_commands.GetAttachedDevices()
|
| - if not attached_devices:
|
| - raise Exception('There are no devices online.')
|
| -
|
| - if options.test_device:
|
| - assert options.test_device in attached_devices
|
| - attached_devices = [options.test_device]
|
| -
|
| - if len(attached_devices) > 1 and options.wait_for_debugger:
|
| - logging.warning('Debugger can not be sharded, using first available device')
|
| - attached_devices = attached_devices[:1]
|
|
|
| def TestRunnerFactory(device, shard_index):
|
| return test_runner.TestRunner(
|
| - options, device, shard_index, test_pkg, [])
|
| + build_type, test_data, install_apk, save_perf_json, screenshot_failures,
|
| + tool, wait_for_debugger, disable_assertions, push_deps,
|
| + cleanup_test_files, device, shard_index, test_pkg, [])
|
|
|
| - return shard.ShardAndRunTests(TestRunnerFactory, attached_devices, tests,
|
| - options.build_type,
|
| - test_timeout=None,
|
| - num_retries=options.num_retries)
|
| + return (TestRunnerFactory, tests)
|
|
|