| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright 2013 The Chromium Authors. All rights reserved. | 3 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Runs all types of tests from one unified interface.""" | 7 """Runs all types of tests from one unified interface.""" |
| 8 | 8 |
| 9 import collections | 9 import collections |
| 10 import logging | 10 import logging |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 option_parser.add_option( | 252 option_parser.add_option( |
| 253 '--test-apk', dest='test_apk', | 253 '--test-apk', dest='test_apk', |
| 254 help=('The name of the apk containing the tests ' | 254 help=('The name of the apk containing the tests ' |
| 255 '(without the .apk extension; e.g. "ContentShellTest").')) | 255 '(without the .apk extension; e.g. "ContentShellTest").')) |
| 256 option_parser.add_option('--coverage-dir', | 256 option_parser.add_option('--coverage-dir', |
| 257 help=('Directory in which to place all generated ' | 257 help=('Directory in which to place all generated ' |
| 258 'EMMA coverage files.')) | 258 'EMMA coverage files.')) |
| 259 option_parser.add_option('--device-flags', dest='device_flags', default='', | 259 option_parser.add_option('--device-flags', dest='device_flags', default='', |
| 260 help='The relative filepath to a file containing ' | 260 help='The relative filepath to a file containing ' |
| 261 'command-line flags to set on the device') | 261 'command-line flags to set on the device') |
| 262 option_parser.add_option('--isolate_file_path', |
| 263 '--isolate-file-path', |
| 264 dest='isolate_file_path', |
| 265 help='.isolate file path to override the default ' |
| 266 'path') |
| 262 | 267 |
| 263 | 268 |
| 264 def ProcessInstrumentationOptions(options, error_func): | 269 def ProcessInstrumentationOptions(options, error_func): |
| 265 """Processes options/arguments and populate |options| with defaults. | 270 """Processes options/arguments and populate |options| with defaults. |
| 266 | 271 |
| 267 Args: | 272 Args: |
| 268 options: optparse.Options object. | 273 options: optparse.Options object. |
| 269 error_func: Function to call with the error message in case of an error. | 274 error_func: Function to call with the error message in case of an error. |
| 270 | 275 |
| 271 Returns: | 276 Returns: |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 options.test_data, | 320 options.test_data, |
| 316 options.save_perf_json, | 321 options.save_perf_json, |
| 317 options.screenshot_failures, | 322 options.screenshot_failures, |
| 318 options.wait_for_debugger, | 323 options.wait_for_debugger, |
| 319 options.coverage_dir, | 324 options.coverage_dir, |
| 320 options.test_apk, | 325 options.test_apk, |
| 321 options.test_apk_path, | 326 options.test_apk_path, |
| 322 options.test_apk_jar_path, | 327 options.test_apk_jar_path, |
| 323 options.test_runner, | 328 options.test_runner, |
| 324 options.test_support_apk_path, | 329 options.test_support_apk_path, |
| 325 options.device_flags | 330 options.device_flags, |
| 331 options.isolate_file_path |
| 326 ) | 332 ) |
| 327 | 333 |
| 328 | 334 |
| 329 def AddUIAutomatorTestOptions(option_parser): | 335 def AddUIAutomatorTestOptions(option_parser): |
| 330 """Adds UI Automator test options to |option_parser|.""" | 336 """Adds UI Automator test options to |option_parser|.""" |
| 331 | 337 |
| 332 option_parser.usage = '%prog uiautomator [options]' | 338 option_parser.usage = '%prog uiautomator [options]' |
| 333 option_parser.commands_dict = {} | 339 option_parser.commands_dict = {} |
| 334 option_parser.example = ( | 340 option_parser.example = ( |
| 335 '%prog uiautomator --test-jar=chrome_shell_uiautomator_tests' | 341 '%prog uiautomator --test-jar=chrome_shell_uiautomator_tests' |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 640 instrumentation_options = ProcessInstrumentationOptions(options, error_func) | 646 instrumentation_options = ProcessInstrumentationOptions(options, error_func) |
| 641 | 647 |
| 642 if len(devices) > 1 and options.wait_for_debugger: | 648 if len(devices) > 1 and options.wait_for_debugger: |
| 643 logging.warning('Debugger can not be sharded, using first available device') | 649 logging.warning('Debugger can not be sharded, using first available device') |
| 644 devices = devices[:1] | 650 devices = devices[:1] |
| 645 | 651 |
| 646 results = base_test_result.TestRunResults() | 652 results = base_test_result.TestRunResults() |
| 647 exit_code = 0 | 653 exit_code = 0 |
| 648 | 654 |
| 649 if options.run_java_tests: | 655 if options.run_java_tests: |
| 650 runner_factory, tests = instrumentation_setup.Setup(instrumentation_options) | 656 runner_factory, tests = instrumentation_setup.Setup( |
| 657 instrumentation_options, devices) |
| 651 | 658 |
| 652 test_results, exit_code = test_dispatcher.RunTests( | 659 test_results, exit_code = test_dispatcher.RunTests( |
| 653 tests, runner_factory, devices, shard=True, test_timeout=None, | 660 tests, runner_factory, devices, shard=True, test_timeout=None, |
| 654 num_retries=options.num_retries) | 661 num_retries=options.num_retries) |
| 655 | 662 |
| 656 results.AddTestRunResults(test_results) | 663 results.AddTestRunResults(test_results) |
| 657 | 664 |
| 658 if options.run_python_tests: | 665 if options.run_python_tests: |
| 659 runner_factory, tests = host_driven_setup.InstrumentationSetup( | 666 runner_factory, tests = host_driven_setup.InstrumentationSetup( |
| 660 options.host_driven_root, options.official_build, | 667 options.host_driven_root, options.official_build, |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 | 951 |
| 945 def main(): | 952 def main(): |
| 946 signal.signal(signal.SIGUSR1, DumpThreadStacks) | 953 signal.signal(signal.SIGUSR1, DumpThreadStacks) |
| 947 option_parser = command_option_parser.CommandOptionParser( | 954 option_parser = command_option_parser.CommandOptionParser( |
| 948 commands_dict=VALID_COMMANDS) | 955 commands_dict=VALID_COMMANDS) |
| 949 return command_option_parser.ParseAndExecute(option_parser) | 956 return command_option_parser.ParseAndExecute(option_parser) |
| 950 | 957 |
| 951 | 958 |
| 952 if __name__ == '__main__': | 959 if __name__ == '__main__': |
| 953 sys.exit(main()) | 960 sys.exit(main()) |
| OLD | NEW |