@@ -111,8 +111,9 @@ def module_has_file(mod):
111
111
class InOrOut (object ):
112
112
"""Machinery for determining what files to measure."""
113
113
114
- def __init__ (self , warn ):
114
+ def __init__ (self , warn , debug ):
115
115
self .warn = warn
116
+ self .debug = debug
116
117
117
118
# The matchers for should_trace.
118
119
self .source_match = None
@@ -177,19 +178,33 @@ def configure(self, config):
177
178
for mod in [contracts , six ]:
178
179
self .cover_paths .append (canonical_path (mod ))
179
180
181
+ def debug (msg ):
182
+ if self .debug :
183
+ self .debug .write (msg )
184
+
180
185
# Create the matchers we need for should_trace
181
186
if self .source or self .source_pkgs :
182
- self .source_match = TreeMatcher (self .source )
183
- self .source_pkgs_match = ModuleMatcher (self .source_pkgs )
187
+ against = []
188
+ if self .source :
189
+ self .source_match = TreeMatcher (self .source )
190
+ against .append ("trees {!r}" .format (self .source_match ))
191
+ if self .source_pkgs :
192
+ self .source_pkgs_match = ModuleMatcher (self .source_pkgs )
193
+ against .append ("modules {!r}" .format (self .source_pkgs_match ))
194
+ debug ("Source matching against " + " and " .join (against ))
184
195
else :
185
196
if self .cover_paths :
186
197
self .cover_match = TreeMatcher (self .cover_paths )
198
+ debug ("Coverage code matching: {!r}" .format (self .cover_match ))
187
199
if self .pylib_paths :
188
200
self .pylib_match = TreeMatcher (self .pylib_paths )
201
+ debug ("Python stdlib matching: {!r}" .format (self .pylib_match ))
189
202
if self .include :
190
203
self .include_match = FnmatchMatcher (self .include )
204
+ debug ("Include matching: {!r}" .format (self .include_match ))
191
205
if self .omit :
192
206
self .omit_match = FnmatchMatcher (self .omit )
207
+ debug ("Omit matching: {!r}" .format (self .omit_match ))
193
208
194
209
def should_trace (self , filename , frame = None ):
195
210
"""Decide whether to trace execution in `filename`, with a reason.
@@ -309,12 +324,21 @@ def check_include_omit_etc(self, filename, frame):
309
324
# about the outer bound of what to measure and we don't have to apply
310
325
# any canned exclusions. If they didn't, then we have to exclude the
311
326
# stdlib and coverage.py directories.
312
- if self .source_match :
313
- if self .source_pkgs_match .match (modulename ):
314
- if modulename in self .source_pkgs_unmatched :
315
- self .source_pkgs_unmatched .remove (modulename )
316
- elif not self .source_match .match (filename ):
317
- return "falls outside the --source trees"
327
+ if self .source_match or self .source_pkgs_match :
328
+ extra = ""
329
+ ok = False
330
+ if self .source_pkgs_match :
331
+ if self .source_pkgs_match .match (modulename ):
332
+ ok = True
333
+ if modulename in self .source_pkgs_unmatched :
334
+ self .source_pkgs_unmatched .remove (modulename )
335
+ else :
336
+ extra = "module {!r} " .format (modulename )
337
+ if not ok and self .source_match :
338
+ if self .source_match .match (filename ):
339
+ ok = True
340
+ if not ok :
341
+ return extra + "falls outside the --source spec"
318
342
elif self .include_match :
319
343
if not self .include_match .match (filename ):
320
344
return "falls outside the --include trees"
0 commit comments