--- a/eric6/DebugClients/Python/coverage/inorout.py Tue Sep 15 19:09:05 2020 +0200 +++ b/eric6/DebugClients/Python/coverage/inorout.py Thu Sep 17 19:10:36 2020 +0200 @@ -111,8 +111,9 @@ class InOrOut(object): """Machinery for determining what files to measure.""" - def __init__(self, warn): + def __init__(self, warn, debug): self.warn = warn + self.debug = debug # The matchers for should_trace. self.source_match = None @@ -131,6 +132,7 @@ def configure(self, config): """Apply the configuration to get ready for decision-time.""" + self.source_pkgs.extend(config.source_pkgs) for src in config.source or []: if os.path.isdir(src): self.source.append(canonical_filename(src)) @@ -177,19 +179,33 @@ for mod in [contracts, six]: self.cover_paths.append(canonical_path(mod)) + def debug(msg): + if self.debug: + self.debug.write(msg) + # Create the matchers we need for should_trace if self.source or self.source_pkgs: - self.source_match = TreeMatcher(self.source) - self.source_pkgs_match = ModuleMatcher(self.source_pkgs) + against = [] + if self.source: + self.source_match = TreeMatcher(self.source) + against.append("trees {!r}".format(self.source_match)) + if self.source_pkgs: + self.source_pkgs_match = ModuleMatcher(self.source_pkgs) + against.append("modules {!r}".format(self.source_pkgs_match)) + debug("Source matching against " + " and ".join(against)) else: if self.cover_paths: self.cover_match = TreeMatcher(self.cover_paths) + debug("Coverage code matching: {!r}".format(self.cover_match)) if self.pylib_paths: self.pylib_match = TreeMatcher(self.pylib_paths) + debug("Python stdlib matching: {!r}".format(self.pylib_match)) if self.include: self.include_match = FnmatchMatcher(self.include) + debug("Include matching: {!r}".format(self.include_match)) if self.omit: self.omit_match = FnmatchMatcher(self.omit) + debug("Omit matching: {!r}".format(self.omit_match)) def should_trace(self, filename, frame=None): """Decide whether to trace execution in `filename`, with a reason. @@ -309,12 +325,21 @@ # about the outer bound of what to measure and we don't have to apply # any canned exclusions. If they didn't, then we have to exclude the # stdlib and coverage.py directories. - if self.source_match: - if self.source_pkgs_match.match(modulename): - if modulename in self.source_pkgs_unmatched: - self.source_pkgs_unmatched.remove(modulename) - elif not self.source_match.match(filename): - return "falls outside the --source trees" + if self.source_match or self.source_pkgs_match: + extra = "" + ok = False + if self.source_pkgs_match: + if self.source_pkgs_match.match(modulename): + ok = True + if modulename in self.source_pkgs_unmatched: + self.source_pkgs_unmatched.remove(modulename) + else: + extra = "module {!r} ".format(modulename) + if not ok and self.source_match: + if self.source_match.match(filename): + ok = True + if not ok: + return extra + "falls outside the --source spec" elif self.include_match: if not self.include_match.match(filename): return "falls outside the --include trees"