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 |
11 import logging | 11 import logging |
12 import os | 12 import os |
13 import shutil | 13 import shutil |
14 import signal | 14 import signal |
15 import sys | 15 import sys |
16 import threading | 16 import threading |
17 import unittest | 17 import unittest |
18 | 18 |
19 from pylib import android_commands | 19 from pylib import android_commands |
20 from pylib import constants | 20 from pylib import constants |
21 from pylib import forwarder | 21 from pylib import forwarder |
22 from pylib import ports | 22 from pylib import ports |
23 from pylib.base import base_error | |
23 from pylib.base import base_test_result | 24 from pylib.base import base_test_result |
24 from pylib.base import environment_factory | 25 from pylib.base import environment_factory |
25 from pylib.base import test_dispatcher | 26 from pylib.base import test_dispatcher |
26 from pylib.base import test_instance_factory | 27 from pylib.base import test_instance_factory |
27 from pylib.base import test_run_factory | 28 from pylib.base import test_run_factory |
28 from pylib.gtest import gtest_config | 29 from pylib.gtest import gtest_config |
29 from pylib.gtest import setup as gtest_setup | 30 from pylib.gtest import setup as gtest_setup |
30 from pylib.gtest import test_options as gtest_test_options | 31 from pylib.gtest import test_options as gtest_test_options |
31 from pylib.linker import setup as linker_setup | 32 from pylib.linker import setup as linker_setup |
32 from pylib.host_driven import setup as host_driven_setup | 33 from pylib.host_driven import setup as host_driven_setup |
(...skipping 917 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('An error occured.') | |
mikecase (-- gone --)
2015/02/23 22:29:27
Just fyi.
logging.exception WILL print the error
jbudorick
2015/02/23 22:31:29
We could split by infra / non-infra?
What does th
mikecase (-- gone --)
2015/02/23 22:48:22
Wrote a quick example. Output of logging.exception
| |
1022 if e.is_infra_error: | |
1023 return constants.INFRA_EXIT_CODE | |
1024 else: | |
1025 return constants.ERROR_EXIT_CODE | |
1017 | 1026 |
1018 | 1027 |
1019 if __name__ == '__main__': | 1028 if __name__ == '__main__': |
1020 sys.exit(main()) | 1029 sys.exit(main()) |
OLD | NEW |