| Index: build/android/test_runner.py
|
| diff --git a/build/android/test_runner.py b/build/android/test_runner.py
|
| index 1baebc1bd69c022f505cf84ea6ee58fc3404f3df..2e39c3c3e31f44d42cf6985ae05de614a0ee3115 100755
|
| --- a/build/android/test_runner.py
|
| +++ b/build/android/test_runner.py
|
| @@ -21,7 +21,10 @@ from pylib import constants
|
| from pylib import forwarder
|
| from pylib import ports
|
| from pylib.base import base_test_result
|
| +from pylib.base import environment_factory
|
| from pylib.base import test_dispatcher
|
| +from pylib.base import test_instance_factory
|
| +from pylib.base import test_run_factory
|
| from pylib.gtest import gtest_config
|
| from pylib.gtest import setup as gtest_setup
|
| from pylib.gtest import test_options as gtest_test_options
|
| @@ -45,9 +48,6 @@ from pylib.utils import reraiser_thread
|
| from pylib.utils import run_tests_helper
|
|
|
|
|
| -HOST_TESTS = ['junit', 'python']
|
| -
|
| -
|
| def AddCommonOptions(option_parser):
|
| """Adds all common options to |option_parser|."""
|
|
|
| @@ -78,15 +78,26 @@ def AddCommonOptions(option_parser):
|
| dest='flakiness_dashboard_server',
|
| help=('Address of the server that is hosting the '
|
| 'Chrome for Android flakiness dashboard.'))
|
| + group.add_option('--enable-platform-mode', action='store_true',
|
| + help=('Run the test scripts in platform mode, which '
|
| + 'conceptually separates the test runner from the '
|
| + '"device" (local or remote, real or emulated) on '
|
| + 'which the tests are running. [experimental]'))
|
| + group.add_option('-e', '--environment', default='local',
|
| + help=('Test environment to run in. Must be one of: %s' %
|
| + ', '.join(constants.VALID_ENVIRONMENTS)))
|
| option_parser.add_option_group(group)
|
|
|
|
|
| -def ProcessCommonOptions(options):
|
| +def ProcessCommonOptions(options, error_func):
|
| """Processes and handles all common options."""
|
| run_tests_helper.SetLogLevel(options.verbose_count)
|
| constants.SetBuildType(options.build_type)
|
| if options.build_directory:
|
| constants.SetBuildDirectory(options.build_directory)
|
| + if options.environment not in constants.VALID_ENVIRONMENTS:
|
| + error_func('--environment must be one of: %s' %
|
| + ', '.join(constants.VALID_ENVIRONMENTS))
|
|
|
|
|
| def AddDeviceOptions(option_parser):
|
| @@ -832,9 +843,12 @@ def RunTestsCommand(command, options, args, option_parser):
|
| option_parser.error('Unrecognized arguments: %s' % (' '.join(args)))
|
| return constants.ERROR_EXIT_CODE
|
|
|
| - ProcessCommonOptions(options)
|
| + ProcessCommonOptions(options, option_parser.error)
|
| +
|
| + if options.enable_platform_mode:
|
| + return RunTestsInPlatformMode(command, options, option_parser)
|
|
|
| - if command in HOST_TESTS:
|
| + if command in constants.LOCAL_MACHINE_TESTS:
|
| devices = []
|
| else:
|
| devices = _GetAttachedDevices(options.test_device)
|
| @@ -863,6 +877,35 @@ def RunTestsCommand(command, options, args, option_parser):
|
| raise Exception('Unknown test type.')
|
|
|
|
|
| +_SUPPORTED_IN_PLATFORM_MODE = [
|
| + # TODO(jbudorick): Add support for more test types.
|
| + 'gtest',
|
| +]
|
| +
|
| +
|
| +def RunTestsInPlatformMode(command, options, option_parser):
|
| +
|
| + if command not in _SUPPORTED_IN_PLATFORM_MODE:
|
| + option_parser.error('%s is not yet supported in platform mode' % command)
|
| +
|
| + with environment_factory.CreateEnvironment(
|
| + command, options, option_parser.error) as env:
|
| + with test_instance_factory.CreateTestInstance(
|
| + command, options, option_parser.error) as test:
|
| + with test_run_factory.CreateTestRun(
|
| + options, env, test, option_parser.error) as test_run:
|
| + results = test_run.RunTests()
|
| +
|
| + report_results.LogFull(
|
| + results=results,
|
| + test_type=test.TestType(),
|
| + test_package=test_run.TestPackage(),
|
| + annotation=options.annotations,
|
| + flakiness_server=options.flakiness_dashboard_server)
|
| +
|
| + return results
|
| +
|
| +
|
| def HelpCommand(command, _options, args, option_parser):
|
| """Display help for a certain command, or overall help.
|
|
|
|
|