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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 api_key_group = group.add_mutually_exclusive_group() | 168 api_key_group = group.add_mutually_exclusive_group() |
169 api_key_group.add_argument('--api-key', default='', | 169 api_key_group.add_argument('--api-key', default='', |
170 help='API key for remote devices.') | 170 help='API key for remote devices.') |
171 api_key_group.add_argument('--api-key-file', default='', | 171 api_key_group.add_argument('--api-key-file', default='', |
172 help='Path to file that contains API key.') | 172 help='Path to file that contains API key.') |
173 | 173 |
174 | 174 |
175 def AddDeviceOptions(parser): | 175 def AddDeviceOptions(parser): |
176 """Adds device options to |parser|.""" | 176 """Adds device options to |parser|.""" |
177 group = parser.add_argument_group(title='Device Options') | 177 group = parser.add_argument_group(title='Device Options') |
178 group.add_argument('-c', dest='cleanup_test_files', | |
179 help='Cleanup test files on the device after run', | |
180 action='store_true') | |
181 group.add_argument('--tool', | 178 group.add_argument('--tool', |
182 dest='tool', | 179 dest='tool', |
183 help=('Run the test under a tool ' | 180 help=('Run the test under a tool ' |
184 '(use --tool help to list them)')) | 181 '(use --tool help to list them)')) |
185 group.add_argument('-d', '--device', dest='test_device', | 182 group.add_argument('-d', '--device', dest='test_device', |
186 help=('Target device for the test suite ' | 183 help=('Target device for the test suite ' |
187 'to run on.')) | 184 'to run on.')) |
188 | 185 |
189 | 186 |
190 def AddGTestOptions(parser): | 187 def AddGTestOptions(parser): |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 constants.SDK_BUILD_TEST_JAVALIB_DIR, | 362 constants.SDK_BUILD_TEST_JAVALIB_DIR, |
366 '%s.jar' % args.test_apk) | 363 '%s.jar' % args.test_apk) |
367 args.test_support_apk_path = '%sSupport%s' % ( | 364 args.test_support_apk_path = '%sSupport%s' % ( |
368 os.path.splitext(args.test_apk_path)) | 365 os.path.splitext(args.test_apk_path)) |
369 | 366 |
370 args.test_runner = apk_helper.GetInstrumentationName(args.test_apk_path) | 367 args.test_runner = apk_helper.GetInstrumentationName(args.test_apk_path) |
371 | 368 |
372 # TODO(jbudorick): Get rid of InstrumentationOptions. | 369 # TODO(jbudorick): Get rid of InstrumentationOptions. |
373 return instrumentation_test_options.InstrumentationOptions( | 370 return instrumentation_test_options.InstrumentationOptions( |
374 args.tool, | 371 args.tool, |
375 args.cleanup_test_files, | |
376 args.annotations, | 372 args.annotations, |
377 args.exclude_annotations, | 373 args.exclude_annotations, |
378 args.test_filter, | 374 args.test_filter, |
379 args.test_data, | 375 args.test_data, |
380 args.save_perf_json, | 376 args.save_perf_json, |
381 args.screenshot_failures, | 377 args.screenshot_failures, |
382 args.wait_for_debugger, | 378 args.wait_for_debugger, |
383 args.coverage_dir, | 379 args.coverage_dir, |
384 args.test_apk, | 380 args.test_apk, |
385 args.test_apk_path, | 381 args.test_apk_path, |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 args.uiautomator_jar = os.path.join( | 426 args.uiautomator_jar = os.path.join( |
431 constants.GetOutDirectory(), | 427 constants.GetOutDirectory(), |
432 constants.SDK_BUILD_JAVALIB_DIR, | 428 constants.SDK_BUILD_JAVALIB_DIR, |
433 '%s.dex.jar' % args.test_jar) | 429 '%s.dex.jar' % args.test_jar) |
434 args.uiautomator_info_jar = ( | 430 args.uiautomator_info_jar = ( |
435 args.uiautomator_jar[:args.uiautomator_jar.find('.dex.jar')] + | 431 args.uiautomator_jar[:args.uiautomator_jar.find('.dex.jar')] + |
436 '_java.jar') | 432 '_java.jar') |
437 | 433 |
438 return uiautomator_test_options.UIAutomatorOptions( | 434 return uiautomator_test_options.UIAutomatorOptions( |
439 args.tool, | 435 args.tool, |
440 args.cleanup_test_files, | |
441 args.annotations, | 436 args.annotations, |
442 args.exclude_annotations, | 437 args.exclude_annotations, |
443 args.test_filter, | 438 args.test_filter, |
444 args.test_data, | 439 args.test_data, |
445 args.save_perf_json, | 440 args.save_perf_json, |
446 args.screenshot_failures, | 441 args.screenshot_failures, |
447 args.uiautomator_jar, | 442 args.uiautomator_jar, |
448 args.uiautomator_info_jar, | 443 args.uiautomator_info_jar, |
449 args.package, | 444 args.package, |
450 args.set_asserts) | 445 args.set_asserts) |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 | 624 |
630 | 625 |
631 def _RunGTests(args, devices): | 626 def _RunGTests(args, devices): |
632 """Subcommand of RunTestsCommands which runs gtests.""" | 627 """Subcommand of RunTestsCommands which runs gtests.""" |
633 exit_code = 0 | 628 exit_code = 0 |
634 for suite_name in args.suite_name: | 629 for suite_name in args.suite_name: |
635 # TODO(jbudorick): Either deprecate multi-suite or move its handling down | 630 # TODO(jbudorick): Either deprecate multi-suite or move its handling down |
636 # into the gtest code. | 631 # into the gtest code. |
637 gtest_options = gtest_test_options.GTestOptions( | 632 gtest_options = gtest_test_options.GTestOptions( |
638 args.tool, | 633 args.tool, |
639 args.cleanup_test_files, | |
640 args.test_filter, | 634 args.test_filter, |
641 args.run_disabled, | 635 args.run_disabled, |
642 args.test_arguments, | 636 args.test_arguments, |
643 args.timeout, | 637 args.timeout, |
644 args.isolate_file_path, | 638 args.isolate_file_path, |
645 suite_name) | 639 suite_name) |
646 runner_factory, tests = gtest_setup.Setup(gtest_options, devices) | 640 runner_factory, tests = gtest_setup.Setup(gtest_options, devices) |
647 | 641 |
648 results, test_exit_code = test_dispatcher.RunTests( | 642 results, test_exit_code = test_dispatcher.RunTests( |
649 tests, runner_factory, devices, shard=True, test_timeout=None, | 643 tests, runner_factory, devices, shard=True, test_timeout=None, |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1023 return constants.INFRA_EXIT_CODE | 1017 return constants.INFRA_EXIT_CODE |
1024 else: | 1018 else: |
1025 return constants.ERROR_EXIT_CODE | 1019 return constants.ERROR_EXIT_CODE |
1026 except: # pylint: disable=W0702 | 1020 except: # pylint: disable=W0702 |
1027 logging.exception('Unrecognized error occurred.') | 1021 logging.exception('Unrecognized error occurred.') |
1028 return constants.ERROR_EXIT_CODE | 1022 return constants.ERROR_EXIT_CODE |
1029 | 1023 |
1030 | 1024 |
1031 if __name__ == '__main__': | 1025 if __name__ == '__main__': |
1032 sys.exit(main()) | 1026 sys.exit(main()) |
OLD | NEW |