| 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 26 matching lines...) Expand all Loading... |
| 37 from pylib.monkey import setup as monkey_setup | 37 from pylib.monkey import setup as monkey_setup |
| 38 from pylib.monkey import test_options as monkey_test_options | 38 from pylib.monkey import test_options as monkey_test_options |
| 39 from pylib.perf import setup as perf_setup | 39 from pylib.perf import setup as perf_setup |
| 40 from pylib.perf import test_options as perf_test_options | 40 from pylib.perf import test_options as perf_test_options |
| 41 from pylib.perf import test_runner as perf_test_runner | 41 from pylib.perf import test_runner as perf_test_runner |
| 42 from pylib.results import json_results | 42 from pylib.results import json_results |
| 43 from pylib.results import report_results | 43 from pylib.results import report_results |
| 44 from pylib.uiautomator import setup as uiautomator_setup | 44 from pylib.uiautomator import setup as uiautomator_setup |
| 45 from pylib.uiautomator import test_options as uiautomator_test_options | 45 from pylib.uiautomator import test_options as uiautomator_test_options |
| 46 from pylib.utils import apk_helper | 46 from pylib.utils import apk_helper |
| 47 from pylib.utils import base_error |
| 47 from pylib.utils import reraiser_thread | 48 from pylib.utils import reraiser_thread |
| 48 from pylib.utils import run_tests_helper | 49 from pylib.utils import run_tests_helper |
| 49 | 50 |
| 50 | 51 |
| 51 def AddCommonOptions(parser): | 52 def AddCommonOptions(parser): |
| 52 """Adds all common options to |parser|.""" | 53 """Adds all common options to |parser|.""" |
| 53 | 54 |
| 54 group = parser.add_argument_group('Common Options') | 55 group = parser.add_argument_group('Common Options') |
| 55 | 56 |
| 56 default_build_type = os.environ.get('BUILDTYPE', 'Debug') | 57 default_build_type = os.environ.get('BUILDTYPE', 'Debug') |
| (...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 results=results, | 951 results=results, |
| 951 test_type=test.TestType(), | 952 test_type=test.TestType(), |
| 952 test_package=test_run.TestPackage(), | 953 test_package=test_run.TestPackage(), |
| 953 annotation=getattr(args, 'annotations', None), | 954 annotation=getattr(args, 'annotations', None), |
| 954 flakiness_server=getattr(args, 'flakiness_dashboard_server', None)) | 955 flakiness_server=getattr(args, 'flakiness_dashboard_server', None)) |
| 955 | 956 |
| 956 if args.json_results_file: | 957 if args.json_results_file: |
| 957 json_results.GenerateJsonResultsFile( | 958 json_results.GenerateJsonResultsFile( |
| 958 results, args.json_results_file) | 959 results, args.json_results_file) |
| 959 | 960 |
| 960 return 0 if results.DidRunPass() else 1 | 961 return 0 if results.DidRunPass() else constants.ERROR_EXIT_CODE |
| 961 | 962 |
| 962 | 963 |
| 963 CommandConfigTuple = collections.namedtuple( | 964 CommandConfigTuple = collections.namedtuple( |
| 964 'CommandConfigTuple', | 965 'CommandConfigTuple', |
| 965 ['add_options_func', 'help_txt']) | 966 ['add_options_func', 'help_txt']) |
| 966 VALID_COMMANDS = { | 967 VALID_COMMANDS = { |
| 967 'gtest': CommandConfigTuple( | 968 'gtest': CommandConfigTuple( |
| 968 AddGTestOptions, | 969 AddGTestOptions, |
| 969 'googletest-based C++ tests'), | 970 'googletest-based C++ tests'), |
| 970 'instrumentation': CommandConfigTuple( | 971 'instrumentation': CommandConfigTuple( |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 command_parsers = parser.add_subparsers(title='test types', | 1007 command_parsers = parser.add_subparsers(title='test types', |
| 1007 dest='command') | 1008 dest='command') |
| 1008 | 1009 |
| 1009 for test_type, config in sorted(VALID_COMMANDS.iteritems(), | 1010 for test_type, config in sorted(VALID_COMMANDS.iteritems(), |
| 1010 key=lambda x: x[0]): | 1011 key=lambda x: x[0]): |
| 1011 subparser = command_parsers.add_parser( | 1012 subparser = command_parsers.add_parser( |
| 1012 test_type, usage='%(prog)s [options]', help=config.help_txt) | 1013 test_type, usage='%(prog)s [options]', help=config.help_txt) |
| 1013 config.add_options_func(subparser) | 1014 config.add_options_func(subparser) |
| 1014 | 1015 |
| 1015 args = parser.parse_args() | 1016 args = parser.parse_args() |
| 1016 return RunTestsCommand(args, parser) | 1017 |
| 1018 try: |
| 1019 return RunTestsCommand(args, parser) |
| 1020 except base_error.BaseError as e: |
| 1021 logging.exception('Error occurred.') |
| 1022 if e.is_infra_error: |
| 1023 return constants.INFRA_EXIT_CODE |
| 1024 else: |
| 1025 return constants.ERROR_EXIT_CODE |
| 1026 except: # pylint: disable=W0702 |
| 1027 logging.exception('Unrecognized error occurred.') |
| 1028 return constants.ERROR_EXIT_CODE |
| 1017 | 1029 |
| 1018 | 1030 |
| 1019 if __name__ == '__main__': | 1031 if __name__ == '__main__': |
| 1020 sys.exit(main()) | 1032 sys.exit(main()) |
| OLD | NEW |