| 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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 group = parser.add_argument_group('JUnit Test Options') | 393 group = parser.add_argument_group('JUnit Test Options') |
| 394 group.add_argument( | 394 group.add_argument( |
| 395 '-s', '--test-suite', dest='test_suite', required=True, | 395 '-s', '--test-suite', dest='test_suite', required=True, |
| 396 help=('JUnit test suite to run.')) | 396 help=('JUnit test suite to run.')) |
| 397 group.add_argument( | 397 group.add_argument( |
| 398 '-f', '--test-filter', dest='test_filter', | 398 '-f', '--test-filter', dest='test_filter', |
| 399 help='Filters tests googletest-style.') | 399 help='Filters tests googletest-style.') |
| 400 group.add_argument( | 400 group.add_argument( |
| 401 '--package-filter', dest='package_filter', | 401 '--package-filter', dest='package_filter', |
| 402 help='Filters tests by package.') | 402 help='Filters tests by package.') |
| 403 # TODO(mikecase): Add --repeat and --break-on-failure to common options. |
| 404 # These options are required for platform-mode support. |
| 405 group.add_argument( |
| 406 '--repeat', dest='repeat', type=int, default=0, |
| 407 help='Number of times to repeat the specified set of tests.') |
| 408 group.add_argument( |
| 409 '--break-on-failure', '--break_on_failure', |
| 410 dest='break_on_failure', action='store_true', |
| 411 help='Whether to break on failure.') |
| 403 group.add_argument( | 412 group.add_argument( |
| 404 '--runner-filter', dest='runner_filter', | 413 '--runner-filter', dest='runner_filter', |
| 405 help='Filters tests by runner class. Must be fully qualified.') | 414 help='Filters tests by runner class. Must be fully qualified.') |
| 406 group.add_argument( | 415 group.add_argument( |
| 407 '--sdk-version', dest='sdk_version', type=int, | |
| 408 help='The Android SDK version.') | |
| 409 group.add_argument( | |
| 410 '--coverage-dir', dest='coverage_dir', type=os.path.realpath, | 416 '--coverage-dir', dest='coverage_dir', type=os.path.realpath, |
| 411 help='Directory to store coverage info.') | 417 help='Directory to store coverage info.') |
| 412 AddCommonOptions(parser) | 418 AddCommonOptions(parser) |
| 413 | 419 |
| 414 | 420 |
| 415 def AddMonkeyTestOptions(parser): | 421 def AddMonkeyTestOptions(parser): |
| 416 """Adds monkey test options to |parser|.""" | 422 """Adds monkey test options to |parser|.""" |
| 417 | 423 |
| 418 group = parser.add_argument_group('Monkey Test Options') | 424 group = parser.add_argument_group('Monkey Test Options') |
| 419 group.add_argument( | 425 group.add_argument( |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 714 elif command == 'python': | 720 elif command == 'python': |
| 715 return _RunPythonTests(args) | 721 return _RunPythonTests(args) |
| 716 else: | 722 else: |
| 717 raise Exception('Unknown test type.') | 723 raise Exception('Unknown test type.') |
| 718 | 724 |
| 719 | 725 |
| 720 _SUPPORTED_IN_PLATFORM_MODE = [ | 726 _SUPPORTED_IN_PLATFORM_MODE = [ |
| 721 # TODO(jbudorick): Add support for more test types. | 727 # TODO(jbudorick): Add support for more test types. |
| 722 'gtest', | 728 'gtest', |
| 723 'instrumentation', | 729 'instrumentation', |
| 730 'junit', |
| 724 'perf', | 731 'perf', |
| 725 ] | 732 ] |
| 726 | 733 |
| 727 | 734 |
| 728 def RunTestsInPlatformMode(args): | 735 def RunTestsInPlatformMode(args): |
| 729 | 736 |
| 730 def infra_error(message): | 737 def infra_error(message): |
| 731 logging.fatal(message) | 738 logging.fatal(message) |
| 732 sys.exit(constants.INFRA_EXIT_CODE) | 739 sys.exit(constants.INFRA_EXIT_CODE) |
| 733 | 740 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 if e.is_infra_error: | 879 if e.is_infra_error: |
| 873 return constants.INFRA_EXIT_CODE | 880 return constants.INFRA_EXIT_CODE |
| 874 return constants.ERROR_EXIT_CODE | 881 return constants.ERROR_EXIT_CODE |
| 875 except: # pylint: disable=W0702 | 882 except: # pylint: disable=W0702 |
| 876 logging.exception('Unrecognized error occurred.') | 883 logging.exception('Unrecognized error occurred.') |
| 877 return constants.ERROR_EXIT_CODE | 884 return constants.ERROR_EXIT_CODE |
| 878 | 885 |
| 879 | 886 |
| 880 if __name__ == '__main__': | 887 if __name__ == '__main__': |
| 881 sys.exit(main()) | 888 sys.exit(main()) |
| OLD | NEW |