OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import argparse | 5 import argparse |
6 import multiprocessing | 6 import multiprocessing |
7 import sys | 7 import sys |
8 | 8 |
9 from .cover import CoverageContext | 9 from .cover import CoverageContext |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 handler=handle_list.ListHandler, | 44 handler=handle_list.ListHandler, |
45 test_glob=[prefix], | 45 test_glob=[prefix], |
46 jobs=1, | 46 jobs=1, |
47 ) | 47 ) |
48 ctx = CoverageContext('', [], False, False) | 48 ctx = CoverageContext('', [], False, False) |
49 result_loop(self._gen, ctx.create_subprocess_context(), options) | 49 result_loop(self._gen, ctx.create_subprocess_context(), options) |
50 return handle_list.ListHandler.COMPLETION_LIST | 50 return handle_list.ListHandler.COMPLETION_LIST |
51 | 51 |
52 | 52 |
53 def _parse_args(args, test_gen): | 53 def _parse_args(args, test_gen): |
54 args = args or sys.argv[1:] | 54 if args is None: |
| 55 args = sys.argv[1:] |
55 | 56 |
56 # Set the default mode if not specified and not passing --help | 57 # Set the default mode if not specified and not passing --help |
57 search_names = set(HANDLERS.keys() + ['-h', '--help']) | 58 search_names = set(HANDLERS.keys() + ['-h', '--help']) |
58 if not any(arg in search_names for arg in args): | 59 if not any(arg in search_names for arg in args): |
59 args.insert(0, 'test') | 60 args.insert(0, 'test') |
60 | 61 |
61 parser = argparse.ArgumentParser() | 62 parser = argparse.ArgumentParser() |
62 subparsers = parser.add_subparsers( | 63 subparsers = parser.add_subparsers( |
63 title='Mode (default "test")', dest='mode', | 64 title='Mode (default "test")', dest='mode', |
64 help='See `[mode] --help` for more options.') | 65 help='See `[mode] --help` for more options.') |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 test_gen, cover_ctx.create_subprocess_context(), opts) | 155 test_gen, cover_ctx.create_subprocess_context(), opts) |
155 | 156 |
156 cover_ctx.cleanup() | 157 cover_ctx.cleanup() |
157 if not killed and not opts.test_glob: | 158 if not killed and not opts.test_glob: |
158 if not cover_ctx.report(verbose=opts.verbose, omit=cover_omit): | 159 if not cover_ctx.report(verbose=opts.verbose, omit=cover_omit): |
159 sys.exit(2) | 160 sys.exit(2) |
160 | 161 |
161 sys.exit(error or killed) | 162 sys.exit(error or killed) |
162 except KeyboardInterrupt: | 163 except KeyboardInterrupt: |
163 pass | 164 pass |
OLD | NEW |