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

Side by Side Diff: expect_tests/main.py

Issue 448013002: Let expect_tests stop walking across certain packages. (Closed) Base URL: https://chromium.googlesource.com/infra/testing/expect_tests.git@master
Patch Set: Reupload Created 6 years, 4 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 | « expect_tests/__init__.py ('k') | 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 multiprocessing 6 import multiprocessing
7 import pkgutil 7 import pkgutil
8 import sys 8 import sys
9 9
10 from expect_tests import handle_list, handle_debug, handle_train, handle_test 10 from expect_tests import handle_list, handle_debug, handle_train, handle_test
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 del opts.test_list 127 del opts.test_list
128 del opts.mode 128 del opts.mode
129 129
130 return opts 130 return opts
131 131
132 132
133 def find_all_modules(): 133 def find_all_modules():
134 sys.path.insert(0, '.') 134 sys.path.insert(0, '.')
135 135
136 ret = [] 136 ret = []
137 blacklist = set()
137 for importer, modname, ispkg in pkgutil.walk_packages(path=['.']): 138 for importer, modname, ispkg in pkgutil.walk_packages(path=['.']):
138 if not ispkg and modname.endswith('_test'): 139 if ispkg and getattr(importer.find_module(modname).load_module(modname),
140 '_expect_tests_stop_walk', False):
141 blacklist.add(modname)
142 continue
143 if modname.endswith('_test'):
144 if any(modname.startswith(pkg) for pkg in blacklist):
145 continue
139 if modname in sys.modules: 146 if modname in sys.modules:
140 ret.append(sys.modules[modname]) 147 ret.append(sys.modules[modname])
141 else: 148 else:
142 ret.append(importer.find_module(modname).load_module(modname)) 149 ret.append(importer.find_module(modname).load_module(modname))
143 150
144 return ret 151 return ret
145 152
146 153
147 def get_test_gens(test_modules): 154 def get_test_gens(test_modules):
148 if test_modules is ALL_MODULES: 155 if test_modules is ALL_MODULES:
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 cover_ctx.cleanup() 209 cover_ctx.cleanup()
203 if (not killed and 210 if (not killed and
204 not skip_loop and ( 211 not skip_loop and (
205 opts.force_coverage or not opts.test_glob)): 212 opts.force_coverage or not opts.test_glob)):
206 if not cover_ctx.report(opts.verbose): 213 if not cover_ctx.report(opts.verbose):
207 sys.exit(2) 214 sys.exit(2)
208 215
209 sys.exit(error or killed) 216 sys.exit(error or killed)
210 except KeyboardInterrupt: 217 except KeyboardInterrupt:
211 pass 218 pass
OLDNEW
« no previous file with comments | « expect_tests/__init__.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698