Chromium Code Reviews| 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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 225 group.add_argument('--tool', | 225 group.add_argument('--tool', |
| 226 dest='tool', | 226 dest='tool', |
| 227 help=('Run the test under a tool ' | 227 help=('Run the test under a tool ' |
| 228 '(use --tool help to list them)')) | 228 '(use --tool help to list them)')) |
| 229 group.add_argument('-d', '--device', dest='test_device', | 229 group.add_argument('-d', '--device', dest='test_device', |
| 230 help=('Target device for the test suite ' | 230 help=('Target device for the test suite ' |
| 231 'to run on.')) | 231 'to run on.')) |
| 232 group.add_argument('--blacklist-file', help='Device blacklist file.') | 232 group.add_argument('--blacklist-file', help='Device blacklist file.') |
| 233 group.add_argument('--enable-device-cache', action='store_true', | 233 group.add_argument('--enable-device-cache', action='store_true', |
| 234 help='Cache device state to disk between runs') | 234 help='Cache device state to disk between runs') |
| 235 group.add_argument('--incremental-install', action='store_true', | |
| 236 help='Use an _incremental apk.') | |
| 237 group.add_argument('--enable-concurrent-adb', action='store_true', | 235 group.add_argument('--enable-concurrent-adb', action='store_true', |
| 238 help='Run multiple adb commands at the same time, even ' | 236 help='Run multiple adb commands at the same time, even ' |
| 239 'for the same device.') | 237 'for the same device.') |
| 240 group.add_argument('--skip-clear-data', action='store_true', | 238 group.add_argument('--skip-clear-data', action='store_true', |
| 241 help='Do not wipe app data between tests. Use this to ' | 239 help='Do not wipe app data between tests. Use this to ' |
| 242 'speed up local development and never on bots ' | 240 'speed up local development and never on bots ' |
| 243 '(increases flakiness)') | 241 '(increases flakiness)') |
| 244 | 242 |
| 245 | 243 |
| 246 def AddGTestOptions(parser): | 244 def AddGTestOptions(parser): |
| 247 """Adds gtest options to |parser|.""" | 245 """Adds gtest options to |parser|.""" |
| 248 | 246 |
| 249 group = parser.add_argument_group('GTest Options') | 247 group = parser.add_argument_group('GTest Options') |
| 250 group.add_argument('-s', '--suite', dest='suite_name', | 248 group.add_argument('-s', '--suite', dest='suite_name', |
| 251 nargs='+', metavar='SUITE_NAME', required=True, | 249 nargs='+', metavar='SUITE_NAME', required=True, |
| 252 help='Executable name of the test suite to run.') | 250 help='Executable name of the test suite to run.') |
| 251 group.add_argument('--test-apk-install-script', | |
|
jbudorick
2016/02/09 20:08:27
If these arguments are going to trigger incrementa
agrieve
2016/02/09 21:43:50
Done.
| |
| 252 help='Path to install script for the test apk.') | |
| 253 group.add_argument('--gtest_also_run_disabled_tests', | 253 group.add_argument('--gtest_also_run_disabled_tests', |
| 254 '--gtest-also-run-disabled-tests', | 254 '--gtest-also-run-disabled-tests', |
| 255 dest='run_disabled', action='store_true', | 255 dest='run_disabled', action='store_true', |
| 256 help='Also run disabled tests if applicable.') | 256 help='Also run disabled tests if applicable.') |
| 257 group.add_argument('-a', '--test-arguments', dest='test_arguments', | 257 group.add_argument('-a', '--test-arguments', dest='test_arguments', |
| 258 default='', | 258 default='', |
| 259 help='Additional arguments to pass to the test.') | 259 help='Additional arguments to pass to the test.') |
| 260 group.add_argument('-t', '--shard-timeout', | 260 group.add_argument('-t', '--shard-timeout', |
| 261 dest='shard_timeout', type=int, default=120, | 261 dest='shard_timeout', type=int, default=120, |
| 262 help='Timeout to wait for each test ' | 262 help='Timeout to wait for each test ' |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 389 java_or_python_group.add_argument( | 389 java_or_python_group.add_argument( |
| 390 '-p', '--python-only', action='store_false', | 390 '-p', '--python-only', action='store_false', |
| 391 dest='run_java_tests', default=True, | 391 dest='run_java_tests', default=True, |
| 392 help='Run only the host-driven tests.') | 392 help='Run only the host-driven tests.') |
| 393 | 393 |
| 394 group.add_argument('--host-driven-root', | 394 group.add_argument('--host-driven-root', |
| 395 help='Root of the host-driven tests.') | 395 help='Root of the host-driven tests.') |
| 396 group.add_argument('-w', '--wait_debugger', dest='wait_for_debugger', | 396 group.add_argument('-w', '--wait_debugger', dest='wait_for_debugger', |
| 397 action='store_true', | 397 action='store_true', |
| 398 help='Wait for debugger.') | 398 help='Wait for debugger.') |
| 399 group.add_argument('--apk-under-test', dest='apk_under_test', | 399 group.add_argument('--apk-under-test', |
| 400 help=('the name of the apk under test.')) | 400 help='Path or name of the apk under test.') |
| 401 group.add_argument('--test-apk', dest='test_apk', required=True, | 401 group.add_argument('--apk-under-test-install-script', |
| 402 help=('The name of the apk containing the tests ' | 402 help='Path to install script for the --apk-under-test.') |
| 403 '(without the .apk extension; ' | 403 group.add_argument('--test-apk', required=True, |
| 404 'e.g. "ContentShellTest").')) | 404 help='Path or name of the apk containing the tests ' |
| 405 '(name is without the .apk extension; ' | |
| 406 'e.g. "ContentShellTest").') | |
| 407 group.add_argument('--test-apk-install-script', | |
| 408 help='Path to install script for the --test-apk.') | |
| 405 group.add_argument('--additional-apk', action='append', | 409 group.add_argument('--additional-apk', action='append', |
| 406 dest='additional_apks', default=[], | 410 dest='additional_apks', default=[], |
| 407 help='Additional apk that must be installed on ' | 411 help='Additional apk that must be installed on ' |
| 408 'the device when the tests are run') | 412 'the device when the tests are run') |
| 409 group.add_argument('--coverage-dir', | 413 group.add_argument('--coverage-dir', |
| 410 help=('Directory in which to place all generated ' | 414 help=('Directory in which to place all generated ' |
| 411 'EMMA coverage files.')) | 415 'EMMA coverage files.')) |
| 412 group.add_argument('--device-flags', dest='device_flags', default='', | 416 group.add_argument('--device-flags', dest='device_flags', default='', |
| 413 help='The relative filepath to a file containing ' | 417 help='The relative filepath to a file containing ' |
| 414 'command-line flags to set on the device') | 418 'command-line flags to set on the device') |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 453 | 457 |
| 454 if os.path.exists(args.test_apk): | 458 if os.path.exists(args.test_apk): |
| 455 args.test_apk_path = args.test_apk | 459 args.test_apk_path = args.test_apk |
| 456 args.test_apk, _ = os.path.splitext(os.path.basename(args.test_apk)) | 460 args.test_apk, _ = os.path.splitext(os.path.basename(args.test_apk)) |
| 457 else: | 461 else: |
| 458 args.test_apk_path = os.path.join( | 462 args.test_apk_path = os.path.join( |
| 459 constants.GetOutDirectory(), | 463 constants.GetOutDirectory(), |
| 460 constants.SDK_BUILD_APKS_DIR, | 464 constants.SDK_BUILD_APKS_DIR, |
| 461 '%s.apk' % args.test_apk) | 465 '%s.apk' % args.test_apk) |
| 462 | 466 |
| 467 jar_basename = args.test_apk | |
| 468 if jar_basename.endswith('_incremental'): | |
| 469 jar_basename = jar_basename[:-12] | |
| 470 | |
| 463 args.test_apk_jar_path = os.path.join( | 471 args.test_apk_jar_path = os.path.join( |
| 464 constants.GetOutDirectory(), | 472 constants.GetOutDirectory(), |
| 465 constants.SDK_BUILD_TEST_JAVALIB_DIR, | 473 constants.SDK_BUILD_TEST_JAVALIB_DIR, |
| 466 '%s.jar' % args.test_apk) | 474 '%s.jar' % jar_basename) |
| 467 args.test_support_apk_path = '%sSupport%s' % ( | 475 args.test_support_apk_path = '%sSupport%s' % ( |
| 468 os.path.splitext(args.test_apk_path)) | 476 os.path.splitext(args.test_apk_path)) |
| 469 | 477 |
| 470 args.test_runner = apk_helper.GetInstrumentationName(args.test_apk_path) | 478 args.test_runner = apk_helper.GetInstrumentationName(args.test_apk_path) |
| 471 | 479 |
| 472 # TODO(jbudorick): Get rid of InstrumentationOptions. | 480 # TODO(jbudorick): Get rid of InstrumentationOptions. |
| 473 return instrumentation_test_options.InstrumentationOptions( | 481 return instrumentation_test_options.InstrumentationOptions( |
| 474 args.tool, | 482 args.tool, |
| 475 args.annotations, | 483 args.annotations, |
| 476 args.exclude_annotations, | 484 args.exclude_annotations, |
| 477 args.test_filter, | 485 args.test_filter, |
| 478 args.test_data, | 486 args.test_data, |
| 479 args.save_perf_json, | 487 args.save_perf_json, |
| 480 args.screenshot_failures, | 488 args.screenshot_failures, |
| 481 args.wait_for_debugger, | 489 args.wait_for_debugger, |
| 482 args.coverage_dir, | 490 args.coverage_dir, |
| 483 args.test_apk, | 491 args.test_apk, |
| 484 args.test_apk_path, | 492 args.test_apk_path, |
| 485 args.test_apk_jar_path, | 493 args.test_apk_jar_path, |
| 486 args.test_runner, | 494 args.test_runner, |
| 487 args.test_support_apk_path, | 495 args.test_support_apk_path, |
| 488 args.device_flags, | 496 args.device_flags, |
| 489 args.isolate_file_path, | 497 args.isolate_file_path, |
| 490 args.set_asserts, | 498 args.set_asserts, |
| 491 args.delete_stale_data, | 499 args.delete_stale_data, |
| 492 args.timeout_scale, | 500 args.timeout_scale, |
| 493 args.apk_under_test, | 501 args.apk_under_test, |
| 494 args.additional_apks, | 502 args.additional_apks, |
| 495 args.strict_mode, | 503 args.strict_mode, |
| 496 args.skip_clear_data) | 504 args.skip_clear_data, |
| 505 args.test_apk_install_script, | |
| 506 args.apk_under_test_install_script) | |
| 497 | 507 |
| 498 | 508 |
| 499 def AddUIAutomatorTestOptions(parser): | 509 def AddUIAutomatorTestOptions(parser): |
| 500 """Adds UI Automator test options to |parser|.""" | 510 """Adds UI Automator test options to |parser|.""" |
| 501 | 511 |
| 502 group = parser.add_argument_group('UIAutomator Test Options') | 512 group = parser.add_argument_group('UIAutomator Test Options') |
| 503 AddJavaTestOptions(group) | 513 AddJavaTestOptions(group) |
| 504 group.add_argument( | 514 group.add_argument( |
| 505 '--package', required=True, choices=constants.PACKAGE_INFO.keys(), | 515 '--package', required=True, choices=constants.PACKAGE_INFO.keys(), |
| 506 metavar='PACKAGE', help='Package under test.') | 516 metavar='PACKAGE', help='Package under test.') |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1127 if e.is_infra_error: | 1137 if e.is_infra_error: |
| 1128 return constants.INFRA_EXIT_CODE | 1138 return constants.INFRA_EXIT_CODE |
| 1129 return constants.ERROR_EXIT_CODE | 1139 return constants.ERROR_EXIT_CODE |
| 1130 except: # pylint: disable=W0702 | 1140 except: # pylint: disable=W0702 |
| 1131 logging.exception('Unrecognized error occurred.') | 1141 logging.exception('Unrecognized error occurred.') |
| 1132 return constants.ERROR_EXIT_CODE | 1142 return constants.ERROR_EXIT_CODE |
| 1133 | 1143 |
| 1134 | 1144 |
| 1135 if __name__ == '__main__': | 1145 if __name__ == '__main__': |
| 1136 sys.exit(main()) | 1146 sys.exit(main()) |
| OLD | NEW |