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