From 261d0c06aeade503e9da4f8e6e522557d01dd298 Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 26 Oct 2017 07:09:11 -0400 Subject: Root is acceptable as a combining path (the manylinux tests end up with one of these) --- coverage/files.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'coverage/files.py') diff --git a/coverage/files.py b/coverage/files.py index 346043da..04ce9cb1 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -302,6 +302,11 @@ class PathAliases(object): def __init__(self): self.aliases = [] + def pprint(self): # pragma: debugging + """Dump the important parts of the PathAliases, for debugging.""" + for regex, result, _, _ in self.aliases: + print("{0!r} --> {1!r}".format(regex.pattern, result)) + def add(self, pattern, result): """Add the `pattern`/`result` pair to the list of aliases. @@ -315,8 +320,10 @@ class PathAliases(object): match an entire tree, and not just its root. """ + if len(pattern) > 1: + pattern = pattern.rstrip(r"\/") + # The pattern can't end with a wildcard component. - pattern = pattern.rstrip(r"\/") if pattern.endswith("*"): raise CoverageException("Pattern must not end with wildcards.") pattern_sep = sep(pattern) @@ -325,7 +332,8 @@ class PathAliases(object): # unless it already is, or is meant to match any prefix. if not pattern.startswith('*') and not isabs_anywhere(pattern): pattern = abs_file(pattern) - pattern += pattern_sep + if not pattern.endswith(pattern_sep): + pattern += pattern_sep # Make a regex from the pattern. fnmatch always adds a \Z to # match the whole string, which we don't want, so we remove the \Z. -- cgit v1.2.1