| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 '--num_retries', '--num-retries', | 56 '--num_retries', '--num-retries', |
| 57 dest='num_retries', type=int, default=2, | 57 dest='num_retries', type=int, default=2, |
| 58 help='Number of retries for a test before ' | 58 help='Number of retries for a test before ' |
| 59 'giving up (default: %(default)s).') | 59 'giving up (default: %(default)s).') |
| 60 parser.add_argument( | 60 parser.add_argument( |
| 61 '--test-launcher-summary-output', | 61 '--test-launcher-summary-output', |
| 62 '--json-results-file', | 62 '--json-results-file', |
| 63 dest='json_results_file', type=os.path.realpath, | 63 dest='json_results_file', type=os.path.realpath, |
| 64 help='If set, will dump results in JSON form ' | 64 help='If set, will dump results in JSON form ' |
| 65 'to specified file.') | 65 'to specified file.') |
| 66 parser.add_argument( |
| 67 '--test-launcher-shard-index', |
| 68 type=int, default=os.environ.get('GTEST_SHARD_INDEX', 0), |
| 69 help='Index of the external shard to run.') |
| 70 parser.add_argument( |
| 71 '--test-launcher-total-shards', |
| 72 type=int, default=os.environ.get('GTEST_TOTAL_SHARDS', 1), |
| 73 help='Total number of external shards.') |
| 66 | 74 |
| 67 return parser | 75 return parser |
| 68 | 76 |
| 69 | 77 |
| 70 def AddTracingOptions(parser): | 78 def AddTracingOptions(parser): |
| 71 # TODO(shenghuazhang): Move this into AddCommonOptions once it's supported | 79 # TODO(shenghuazhang): Move this into AddCommonOptions once it's supported |
| 72 # for all test types. | 80 # for all test types. |
| 73 parser.add_argument( | 81 parser.add_argument( |
| 74 '--trace-output', | 82 '--trace-output', |
| 75 metavar='FILENAME', type=os.path.realpath, | 83 metavar='FILENAME', type=os.path.realpath, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 AddTestLauncherArgs(parser) | 163 AddTestLauncherArgs(parser) |
| 156 | 164 |
| 157 | 165 |
| 158 def ProcessCommonOptions(args): | 166 def ProcessCommonOptions(args): |
| 159 """Processes and handles all common options.""" | 167 """Processes and handles all common options.""" |
| 160 run_tests_helper.SetLogLevel(args.verbose_count) | 168 run_tests_helper.SetLogLevel(args.verbose_count) |
| 161 constants.SetBuildType(args.build_type) | 169 constants.SetBuildType(args.build_type) |
| 162 if args.output_directory: | 170 if args.output_directory: |
| 163 constants.SetOutputDirectory(args.output_directory) | 171 constants.SetOutputDirectory(args.output_directory) |
| 164 | 172 |
| 165 # Some things such as Forwarder require ADB to be in the environment path. | |
| 166 adb_dir = os.path.dirname(constants.GetAdbPath()) | |
| 167 if adb_dir and adb_dir not in os.environ['PATH'].split(os.pathsep): | |
| 168 os.environ['PATH'] = adb_dir + os.pathsep + os.environ['PATH'] | |
| 169 | |
| 170 | 173 |
| 171 def AddDeviceOptions(parser): | 174 def AddDeviceOptions(parser): |
| 172 """Adds device options to |parser|.""" | 175 """Adds device options to |parser|.""" |
| 173 | 176 |
| 174 parser = parser.add_argument_group('device arguments') | 177 parser = parser.add_argument_group('device arguments') |
| 175 | 178 |
| 176 parser.add_argument( | 179 parser.add_argument( |
| 177 '--adb-path', | 180 '--adb-path', |
| 178 type=os.path.realpath, | 181 type=os.path.realpath, |
| 179 help='Specify the absolute path of the adb binary that ' | 182 help='Specify the absolute path of the adb binary that ' |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 if e.is_infra_error: | 877 if e.is_infra_error: |
| 875 return constants.INFRA_EXIT_CODE | 878 return constants.INFRA_EXIT_CODE |
| 876 return constants.ERROR_EXIT_CODE | 879 return constants.ERROR_EXIT_CODE |
| 877 except: # pylint: disable=W0702 | 880 except: # pylint: disable=W0702 |
| 878 logging.exception('Unrecognized error occurred.') | 881 logging.exception('Unrecognized error occurred.') |
| 879 return constants.ERROR_EXIT_CODE | 882 return constants.ERROR_EXIT_CODE |
| 880 | 883 |
| 881 | 884 |
| 882 if __name__ == '__main__': | 885 if __name__ == '__main__': |
| 883 sys.exit(main()) | 886 sys.exit(main()) |
| OLD | NEW |