| Index: build/android/test_runner.py
|
| diff --git a/build/android/test_runner.py b/build/android/test_runner.py
|
| index f50bc7cb82b131efb488617d89f70796d84c7f5c..a58d935b707255f66bb1b3bbd713335ac7b85c8b 100755
|
| --- a/build/android/test_runner.py
|
| +++ b/build/android/test_runner.py
|
| @@ -16,16 +16,18 @@ import os
|
| import shutil
|
| import sys
|
|
|
| -from pylib import cmd_helper
|
| from pylib import constants
|
| from pylib import ports
|
| from pylib.base import base_test_result
|
| from pylib.base import test_dispatcher
|
| from pylib.browsertests import setup as browsertests_setup
|
| -from pylib.gtest import setup as gtest_setup
|
| from pylib.gtest import gtest_config
|
| +from pylib.gtest import setup as gtest_setup
|
| from pylib.host_driven import run_python_tests as python_dispatch
|
| from pylib.instrumentation import setup as instrumentation_setup
|
| +from pylib.test_options import GTestOptions
|
| +from pylib.test_options import InstrumentationOptions
|
| +from pylib.test_options import UIAutomatorOptions
|
| from pylib.uiautomator import setup as uiautomator_setup
|
| from pylib.utils import report_results
|
| from pylib.utils import run_tests_helper
|
| @@ -148,15 +150,12 @@ def ProcessGTestOptions(options):
|
|
|
| Args:
|
| options: Command line options.
|
| -
|
| - Returns:
|
| - True if the command should continue.
|
| """
|
| if options.suite_name == 'help':
|
| print 'Available test suites are:'
|
| for test_suite in gtest_config.STABLE_TEST_SUITES:
|
| print test_suite.name
|
| - return False
|
| + sys.exit(0)
|
|
|
| # Convert to a list, assuming all test suites if nothing was specified.
|
| # TODO(gkanwar): Require having a test suite
|
| @@ -165,7 +164,6 @@ def ProcessGTestOptions(options):
|
| else:
|
| options.suite_name = [suite.name
|
| for suite in gtest_config.STABLE_TEST_SUITES]
|
| - return True
|
|
|
|
|
| def AddJavaTestOptions(option_parser):
|
| @@ -275,7 +273,16 @@ def AddInstrumentationTestOptions(option_parser):
|
|
|
|
|
| def ProcessInstrumentationOptions(options, error_func):
|
| - """Processes options/arguments and populate |options| with defaults."""
|
| + """Processes options/arguments and populate |options| with defaults.
|
| +
|
| + Args:
|
| + options: optparse.Options object.
|
| + error_func: Function to call with the error message in case of an error.
|
| +
|
| + Returns:
|
| + An InstrumentationOptions named tuple which contains all options relevant to
|
| + instrumentation tests.
|
| + """
|
|
|
| ProcessJavaTestOptions(options, error_func)
|
|
|
| @@ -296,6 +303,23 @@ def ProcessInstrumentationOptions(options, error_func):
|
| _SDK_OUT_DIR, options.build_type, constants.SDK_BUILD_TEST_JAVALIB_DIR,
|
| '%s.jar' % options.test_apk)
|
|
|
| + return InstrumentationOptions(options.build_type,
|
| + options.annotations,
|
| + options.exclude_annotations,
|
| + options.test_filter,
|
| + options.test_data,
|
| + options.save_perf_json,
|
| + options.screenshot_failures,
|
| + options.tool,
|
| + options.disable_assertions,
|
| + options.push_deps,
|
| + options.cleanup_test_files,
|
| + options.wait_for_debugger,
|
| + options.install_apk,
|
| + options.test_apk,
|
| + options.test_apk_path,
|
| + options.test_apk_jar_path)
|
| +
|
|
|
| def AddUIAutomatorTestOptions(option_parser):
|
| """Adds UI Automator test options to |option_parser|."""
|
| @@ -319,7 +343,16 @@ def AddUIAutomatorTestOptions(option_parser):
|
|
|
|
|
| def ProcessUIAutomatorOptions(options, error_func):
|
| - """Processes UIAutomator options/arguments."""
|
| + """Processes UIAutomator options/arguments.
|
| +
|
| + Args:
|
| + options: optparse.Options object.
|
| + error_func: Function to call with the error message in case of an error.
|
| +
|
| + Returns:
|
| + A UIAutomatorOptions named tuple which contains all options relevant to
|
| + instrumentation tests.
|
| + """
|
|
|
| ProcessJavaTestOptions(options, error_func)
|
|
|
| @@ -340,18 +373,40 @@ def ProcessUIAutomatorOptions(options, error_func):
|
| options.uiautomator_jar[:options.uiautomator_jar.find('.dex.jar')] +
|
| '_java.jar')
|
|
|
| + return UIAutomatorOptions(options.build_type,
|
| + options.annotations,
|
| + options.exclude_annotations,
|
| + options.test_filter,
|
| + options.test_data,
|
| + options.save_perf_json,
|
| + options.screenshot_failures,
|
| + options.tool,
|
| + options.disable_assertions,
|
| + options.push_deps,
|
| + options.cleanup_test_files,
|
| + options.uiautomator_jar,
|
| + options.uiautomator_info_jar,
|
| + options.package_name)
|
| +
|
|
|
| def _RunGTests(options, error_func):
|
| """Subcommand of RunTestsCommands which runs gtests."""
|
| - if not ProcessGTestOptions(options):
|
| - return 0
|
| + ProcessGTestOptions(options)
|
|
|
| exit_code = 0
|
| for suite_name in options.suite_name:
|
| - runner_factory, tests = gtest_setup.Setup(
|
| - options.exe, suite_name, options.test_arguments,
|
| - options.timeout, options.cleanup_test_files, options.tool,
|
| - options.build_type, options.push_deps, options.test_filter)
|
| + # TODO(gkanwar): Move this into ProcessGTestOptions once we require -s for
|
| + # the gtest command.
|
| + gtest_options = GTestOptions(options.build_type,
|
| + options.tool,
|
| + options.cleanup_test_files,
|
| + options.push_deps,
|
| + options.test_filter,
|
| + options.test_arguments,
|
| + options.exe,
|
| + options.timeout,
|
| + suite_name)
|
| + runner_factory, tests = gtest_setup.Setup(gtest_options)
|
|
|
| results, test_exit_code = test_dispatcher.RunTests(
|
| tests, runner_factory, False, options.test_device,
|
| @@ -378,10 +433,16 @@ def _RunGTests(options, error_func):
|
|
|
| def _RunContentBrowserTests(options, error_func):
|
| """Subcommand of RunTestsCommands which runs content_browsertests."""
|
| - runner_factory, tests = browsertests_setup.Setup(
|
| - options.test_arguments, options.timeout, options.cleanup_test_files,
|
| - options.tool, options.build_type, options.push_deps,
|
| - options.test_filter)
|
| + gtest_options = GTestOptions(options.build_type,
|
| + options.tool,
|
| + options.cleanup_test_files,
|
| + options.push_deps,
|
| + options.test_filter,
|
| + options.test_arguments,
|
| + options.exe,
|
| + options.timeout,
|
| + constants.BROWSERTEST_SUITE_NAME)
|
| + runner_factory, tests = browsertests_setup.Setup(gtest_options)
|
|
|
| # TODO(nileshagrawal): remove this abnormally long setup timeout once fewer
|
| # files are pushed to the devices for content_browsertests: crbug.com/138275
|
| @@ -409,19 +470,13 @@ def _RunContentBrowserTests(options, error_func):
|
|
|
| def _RunInstrumentationTests(options, error_func):
|
| """Subcommand of RunTestsCommands which runs instrumentation tests."""
|
| - ProcessInstrumentationOptions(options, error_func)
|
| + instrumentation_options = ProcessInstrumentationOptions(options, error_func)
|
|
|
| results = base_test_result.TestRunResults()
|
| exit_code = 0
|
|
|
| if options.run_java_tests:
|
| - runner_factory, tests = instrumentation_setup.Setup(
|
| - options.test_apk_path, options.test_apk_jar_path, options.annotations,
|
| - options.exclude_annotations, options.test_filter, options.build_type,
|
| - options.test_data, options.install_apk, options.save_perf_json,
|
| - options.screenshot_failures, options.tool, options.wait_for_debugger,
|
| - options.disable_assertions, options.push_deps,
|
| - options.cleanup_test_files)
|
| + runner_factory, tests = instrumentation_setup.Setup(instrumentation_options)
|
|
|
| test_results, exit_code = test_dispatcher.RunTests(
|
| tests, runner_factory, options.wait_for_debugger,
|
| @@ -456,19 +511,13 @@ def _RunInstrumentationTests(options, error_func):
|
|
|
| def _RunUIAutomatorTests(options, error_func):
|
| """Subcommand of RunTestsCommands which runs uiautomator tests."""
|
| - ProcessUIAutomatorOptions(options, error_func)
|
| + uiautomator_options = ProcessUIAutomatorOptions(options, error_func)
|
|
|
| results = base_test_result.TestRunResults()
|
| exit_code = 0
|
|
|
| if options.run_java_tests:
|
| - runner_factory, tests = uiautomator_setup.Setup(
|
| - options.uiautomator_jar, options.uiautomator_info_jar,
|
| - options.annotations, options.exclude_annotations, options.test_filter,
|
| - options.package_name, options.build_type, options.test_data,
|
| - options.save_perf_json, options.screenshot_failures, options.tool,
|
| - options.disable_assertions, options.push_deps,
|
| - options.cleanup_test_files)
|
| + runner_factory, tests = uiautomator_setup.Setup(uiautomator_options)
|
|
|
| test_results, exit_code = test_dispatcher.RunTests(
|
| tests, runner_factory, False, options.test_device,
|
|
|