| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 opts.test_glob += [l.strip() for l in tl.readlines()] | 114 opts.test_glob += [l.strip() for l in tl.readlines()] |
| 115 | 115 |
| 116 opts.handler = HANDLERS[opts.mode] | 116 opts.handler = HANDLERS[opts.mode] |
| 117 | 117 |
| 118 del opts.test_list | 118 del opts.test_list |
| 119 del opts.mode | 119 del opts.mode |
| 120 | 120 |
| 121 return opts | 121 return opts |
| 122 | 122 |
| 123 | 123 |
| 124 def main(name, test_gen, cover_branches=False, args=None): | 124 def main(name, test_gen, cover_branches=False, cover_omit=None, args=None): |
| 125 """Entry point for tests using expect_tests. | 125 """Entry point for tests using expect_tests. |
| 126 | 126 |
| 127 Example: | 127 Example: |
| 128 import expect_tests | 128 import expect_tests |
| 129 | 129 |
| 130 def happy_fn(val): | 130 def happy_fn(val): |
| 131 # Usually you would return data which is the result of some deterministic | 131 # Usually you would return data which is the result of some deterministic |
| 132 # computation. | 132 # computation. |
| 133 return expect_tests.Result({'neet': '%s string value' % val}) | 133 return expect_tests.Result({'neet': '%s string value' % val}) |
| 134 | 134 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 148 opts = _parse_args(args, test_gen) | 148 opts = _parse_args(args, test_gen) |
| 149 | 149 |
| 150 cover_ctx = CoverageContext(name, cover_branches, opts.html_report, | 150 cover_ctx = CoverageContext(name, cover_branches, opts.html_report, |
| 151 not opts.handler.SKIP_RUNLOOP) | 151 not opts.handler.SKIP_RUNLOOP) |
| 152 | 152 |
| 153 error, killed = result_loop( | 153 error, killed = result_loop( |
| 154 test_gen, cover_ctx.create_subprocess_context(), opts) | 154 test_gen, cover_ctx.create_subprocess_context(), opts) |
| 155 | 155 |
| 156 cover_ctx.cleanup() | 156 cover_ctx.cleanup() |
| 157 if not killed and not opts.test_glob: | 157 if not killed and not opts.test_glob: |
| 158 if not cover_ctx.report(opts.verbose): | 158 if not cover_ctx.report(verbose=opts.verbose, omit=cover_omit): |
| 159 sys.exit(2) | 159 sys.exit(2) |
| 160 | 160 |
| 161 sys.exit(error or killed) | 161 sys.exit(error or killed) |
| 162 except KeyboardInterrupt: | 162 except KeyboardInterrupt: |
| 163 pass | 163 pass |
| OLD | NEW |