| 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 argparse | 9 import argparse |
| 10 import collections | 10 import collections |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 default='', | 208 default='', |
| 209 help='Additional arguments to pass to the test.') | 209 help='Additional arguments to pass to the test.') |
| 210 group.add_argument('-t', dest='timeout', type=int, default=60, | 210 group.add_argument('-t', dest='timeout', type=int, default=60, |
| 211 help='Timeout to wait for each test ' | 211 help='Timeout to wait for each test ' |
| 212 '(default: %(default)s).') | 212 '(default: %(default)s).') |
| 213 group.add_argument('--isolate_file_path', | 213 group.add_argument('--isolate_file_path', |
| 214 '--isolate-file-path', | 214 '--isolate-file-path', |
| 215 dest='isolate_file_path', | 215 dest='isolate_file_path', |
| 216 help='.isolate file path to override the default ' | 216 help='.isolate file path to override the default ' |
| 217 'path') | 217 'path') |
| 218 group.add_argument('--delete-stale-data', dest='delete_stale_data', |
| 219 action='store_true', |
| 220 help='Delete stale test data on the device.') |
| 218 | 221 |
| 219 filter_group = group.add_mutually_exclusive_group() | 222 filter_group = group.add_mutually_exclusive_group() |
| 220 filter_group.add_argument('-f', '--gtest_filter', '--gtest-filter', | 223 filter_group.add_argument('-f', '--gtest_filter', '--gtest-filter', |
| 221 dest='test_filter', | 224 dest='test_filter', |
| 222 help='googletest-style filter string.') | 225 help='googletest-style filter string.') |
| 223 filter_group.add_argument('--gtest-filter-file', dest='test_filter_file', | 226 filter_group.add_argument('--gtest-filter-file', dest='test_filter_file', |
| 224 help='Path to file that contains googletest-style ' | 227 help='Path to file that contains googletest-style ' |
| 225 'filter strings. (Lines will be joined with ' | 228 'filter strings. (Lines will be joined with ' |
| 226 '":" to create a single filter string.)') | 229 '":" to create a single filter string.)') |
| 227 | 230 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 help='The relative filepath to a file containing ' | 331 help='The relative filepath to a file containing ' |
| 329 'command-line flags to set on the device') | 332 'command-line flags to set on the device') |
| 330 group.add_argument('--device-flags-file', default='', | 333 group.add_argument('--device-flags-file', default='', |
| 331 help='The relative filepath to a file containing ' | 334 help='The relative filepath to a file containing ' |
| 332 'command-line flags to set on the device') | 335 'command-line flags to set on the device') |
| 333 group.add_argument('--isolate_file_path', | 336 group.add_argument('--isolate_file_path', |
| 334 '--isolate-file-path', | 337 '--isolate-file-path', |
| 335 dest='isolate_file_path', | 338 dest='isolate_file_path', |
| 336 help='.isolate file path to override the default ' | 339 help='.isolate file path to override the default ' |
| 337 'path') | 340 'path') |
| 341 group.add_argument('--delete-stale-data', dest='delete_stale_data', |
| 342 action='store_true', |
| 343 help='Delete stale test data on the device.') |
| 338 | 344 |
| 339 AddCommonOptions(parser) | 345 AddCommonOptions(parser) |
| 340 AddDeviceOptions(parser) | 346 AddDeviceOptions(parser) |
| 341 AddRemoteDeviceOptions(parser) | 347 AddRemoteDeviceOptions(parser) |
| 342 | 348 |
| 343 | 349 |
| 344 def ProcessInstrumentationOptions(args): | 350 def ProcessInstrumentationOptions(args): |
| 345 """Processes options/arguments and populate |options| with defaults. | 351 """Processes options/arguments and populate |options| with defaults. |
| 346 | 352 |
| 347 Args: | 353 Args: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 args.screenshot_failures, | 387 args.screenshot_failures, |
| 382 args.wait_for_debugger, | 388 args.wait_for_debugger, |
| 383 args.coverage_dir, | 389 args.coverage_dir, |
| 384 args.test_apk, | 390 args.test_apk, |
| 385 args.test_apk_path, | 391 args.test_apk_path, |
| 386 args.test_apk_jar_path, | 392 args.test_apk_jar_path, |
| 387 args.test_runner, | 393 args.test_runner, |
| 388 args.test_support_apk_path, | 394 args.test_support_apk_path, |
| 389 args.device_flags, | 395 args.device_flags, |
| 390 args.isolate_file_path, | 396 args.isolate_file_path, |
| 391 args.set_asserts | 397 args.set_asserts, |
| 398 args.delete_stale_data |
| 392 ) | 399 ) |
| 393 | 400 |
| 394 | 401 |
| 395 def AddUIAutomatorTestOptions(parser): | 402 def AddUIAutomatorTestOptions(parser): |
| 396 """Adds UI Automator test options to |parser|.""" | 403 """Adds UI Automator test options to |parser|.""" |
| 397 | 404 |
| 398 group = parser.add_argument_group('UIAutomator Test Options') | 405 group = parser.add_argument_group('UIAutomator Test Options') |
| 399 AddJavaTestOptions(group) | 406 AddJavaTestOptions(group) |
| 400 group.add_argument( | 407 group.add_argument( |
| 401 '--package', required=True, choices=constants.PACKAGE_INFO.keys(), | 408 '--package', required=True, choices=constants.PACKAGE_INFO.keys(), |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 for suite_name in args.suite_name: | 640 for suite_name in args.suite_name: |
| 634 # TODO(jbudorick): Either deprecate multi-suite or move its handling down | 641 # TODO(jbudorick): Either deprecate multi-suite or move its handling down |
| 635 # into the gtest code. | 642 # into the gtest code. |
| 636 gtest_options = gtest_test_options.GTestOptions( | 643 gtest_options = gtest_test_options.GTestOptions( |
| 637 args.tool, | 644 args.tool, |
| 638 args.test_filter, | 645 args.test_filter, |
| 639 args.run_disabled, | 646 args.run_disabled, |
| 640 args.test_arguments, | 647 args.test_arguments, |
| 641 args.timeout, | 648 args.timeout, |
| 642 args.isolate_file_path, | 649 args.isolate_file_path, |
| 643 suite_name) | 650 suite_name, |
| 651 args.delete_stale_data) |
| 644 runner_factory, tests = gtest_setup.Setup(gtest_options, devices) | 652 runner_factory, tests = gtest_setup.Setup(gtest_options, devices) |
| 645 | 653 |
| 646 results, test_exit_code = test_dispatcher.RunTests( | 654 results, test_exit_code = test_dispatcher.RunTests( |
| 647 tests, runner_factory, devices, shard=True, test_timeout=None, | 655 tests, runner_factory, devices, shard=True, test_timeout=None, |
| 648 num_retries=args.num_retries) | 656 num_retries=args.num_retries) |
| 649 | 657 |
| 650 if test_exit_code and exit_code != constants.ERROR_EXIT_CODE: | 658 if test_exit_code and exit_code != constants.ERROR_EXIT_CODE: |
| 651 exit_code = test_exit_code | 659 exit_code = test_exit_code |
| 652 | 660 |
| 653 report_results.LogFull( | 661 report_results.LogFull( |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1027 if e.is_infra_error: | 1035 if e.is_infra_error: |
| 1028 return constants.INFRA_EXIT_CODE | 1036 return constants.INFRA_EXIT_CODE |
| 1029 return constants.ERROR_EXIT_CODE | 1037 return constants.ERROR_EXIT_CODE |
| 1030 except: # pylint: disable=W0702 | 1038 except: # pylint: disable=W0702 |
| 1031 logging.exception('Unrecognized error occurred.') | 1039 logging.exception('Unrecognized error occurred.') |
| 1032 return constants.ERROR_EXIT_CODE | 1040 return constants.ERROR_EXIT_CODE |
| 1033 | 1041 |
| 1034 | 1042 |
| 1035 if __name__ == '__main__': | 1043 if __name__ == '__main__': |
| 1036 sys.exit(main()) | 1044 sys.exit(main()) |
| OLD | NEW |