Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: expect_tests/main.py

Issue 1915163005: expect_tests: add options to enable per-module runs. (Closed) Base URL: https://chromium.googlesource.com/infra/testing/expect_tests.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 logging 6 import logging
7 import multiprocessing 7 import multiprocessing
8 import os 8 import os
9 import sys 9 import sys
10 10
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 sp.add_argument( 54 sp.add_argument(
55 '--force-coverage', '--force_coverage', action='store_true', 55 '--force-coverage', '--force_coverage', action='store_true',
56 help='Enable coverage report even when specifying a test filter.') 56 help='Enable coverage report even when specifying a test filter.')
57 57
58 sp.add_argument( 58 sp.add_argument(
59 '--no-coverage', '--no_coverage', action='store_true', 59 '--no-coverage', '--no_coverage', action='store_true',
60 help='Disable coverage report.') 60 help='Disable coverage report.')
61 61
62 sp.add_argument( 62 sp.add_argument(
63 '--coveragerc', metavar='FILE',
64 help='File to read coverage configuration. Default: .coveragerc')
65
66 sp.add_argument(
63 '--test-list', '--test_list', metavar='FILE', 67 '--test-list', '--test_list', metavar='FILE',
64 help='take the list of test globs from the FILE (use "-" for stdin)' 68 help='take the list of test globs from the FILE (use "-" for stdin)'
65 ).completer = lambda **_: [] 69 ).completer = lambda **_: []
66 70
67 sp.add_argument( 71 sp.add_argument(
68 '--html-report', '--html_report', metavar='DIR', 72 '--html-report', '--html_report', metavar='DIR',
69 help='directory to write html report (default: disabled)' 73 help='directory to write html report (default: disabled)'
70 ).completer = lambda **_: [] 74 ).completer = lambda **_: []
71 75
72 sp.add_argument( 76 sp.add_argument(
77 '--html-report-subdir', '--html_report_subdir', metavar='DIR',
78 help=('additional relative path within --html-report to write html '
79 'report (default: empty)'))
80
81 sp.add_argument(
73 '--leak-temp', '--leak_temp', action='store_true', 82 '--leak-temp', '--leak_temp', action='store_true',
74 help='leak temporary directory for debugging (default: False)' 83 help='leak temporary directory for debugging (default: False)'
75 ) 84 )
76 85
77 sp.add_argument( 86 sp.add_argument(
78 'test_glob', nargs='*', help=( 87 'test_glob', nargs='*', help=(
79 'paths to look for tests in. It can be a directory containing ' 88 'paths to look for tests in. It can be a directory containing '
80 'packages, a package, a file inside a package or a test inside a ' 89 'packages, a package, a file inside a package or a test inside a '
81 'file (append the name of the test to the path using a colon)') 90 'file (append the name of the test to the path using a colon)')
82 ) 91 )
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 orig_parse_args = argparse.ArgumentParser.parse_args 154 orig_parse_args = argparse.ArgumentParser.parse_args
146 def new_parse_args(self, *args, **kwargs): 155 def new_parse_args(self, *args, **kwargs):
147 argcomplete.autocomplete(self) 156 argcomplete.autocomplete(self)
148 return orig_parse_args(*args, **kwargs) 157 return orig_parse_args(*args, **kwargs)
149 argparse.ArgumentParser.parse_args = new_parse_args 158 argparse.ArgumentParser.parse_args = new_parse_args
150 159
151 try: 160 try:
152 opts = _parse_args(args) 161 opts = _parse_args(args)
153 skip_loop = opts.handler.SKIP_RUNLOOP 162 skip_loop = opts.handler.SKIP_RUNLOOP
154 163
155 cover_ctx = CoverageContext(cover_branches, opts.html_report, 164 html_report = opts.html_report
156 not skip_loop) 165 if html_report and opts.html_report_subdir:
166 html_report = os.path.join(html_report, opts.html_report_subdir)
167
168 cover_ctx = CoverageContext(cover_branches, html_report,
169 enabled=not skip_loop,
170 coveragerc=opts.coveragerc)
157 171
158 # This is a quick hack to disable rude modules from implicitly configuring 172 # This is a quick hack to disable rude modules from implicitly configuring
159 # basic logging at import-time. 173 # basic logging at import-time.
160 map(logging.getLogger().removeHandler, logging.getLogger().handlers) 174 map(logging.getLogger().removeHandler, logging.getLogger().handlers)
161 175
162 with TempDir(opts.leak_temp): 176 with TempDir(opts.leak_temp):
163 error, killed = result_loop(cover_ctx.create_subprocess_context(), opts) 177 error, killed = result_loop(cover_ctx.create_subprocess_context(), opts)
164 178
165 cover_ctx.cleanup() 179 cover_ctx.cleanup()
166 if (not killed and 180 if (not killed and
167 (not opts.test_glob or 181 (not opts.test_glob or
168 opts.coverage)): 182 opts.coverage)):
169 if not cover_ctx.report(opts.verbose): 183 if not cover_ctx.report(opts.verbose):
170 sys.exit(2) 184 sys.exit(2)
171 185
172 sys.exit(error or killed) 186 sys.exit(error or killed)
173 except KeyboardInterrupt: 187 except KeyboardInterrupt:
174 pass 188 pass
175 189
176 190
177 # This script is invoked from scripts/expect_tests. 191 # This script is invoked from scripts/expect_tests.
178 if __name__ == '__main__': 192 if __name__ == '__main__':
179 main() 193 main()
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698