Skip to content

Commit

Permalink
Add regression test for path w/ trailing wildcard
Browse files Browse the repository at this point in the history
This patch demonstrates a corner case in the path glob matcher.
Specifically, it documents how a single trailing asterisk is supposed
to be treated as opposed to a double asterisk.
With [[1]], a trailing `/*` is interpreted as an equivalent of `/**`.
The commit add a case that shows that `/*` shouldn't be greedy as
described in the docs [[2]][[3]].

See also the observations in the bug report ticket [[4]].

[1]: nedbat@ec6205a
[2]: https://coverage.rtfd.io/en/stable/source.html#file-patterns
[3]: https://coverage.rtfd.io/en/7.2.7/migrating.html#migrating-to-coverage-py-7-x
[4]: nedbat#1407 (comment)
  • Loading branch information
webknjaz committed Aug 11, 2023
1 parent da7ee52 commit b2d780d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tests/test_files.py
Expand Up @@ -348,11 +348,14 @@ def test_glob_matcher(self) -> None:
(self.make_file("sub/file1.py"), True),
(self.make_file("sub/file2.c"), False),
(self.make_file("sub2/file3.h"), True),
(self.make_file("sub2/sub/file3.h"), False),
(self.make_file("sub3/file4.py"), True),
(self.make_file("sub3/file5.c"), False),
(self.make_file("sub4/file3.h"), True),
(self.make_file("sub4/sub/file3.h"), True),
]
fnm = GlobMatcher(["*.py", "*/sub2/*"])
assert fnm.info() == ["*.py", "*/sub2/*"]
fnm = GlobMatcher(["*.py", "*/sub2/*", "*/sub4/**"])
assert fnm.info() == ["*.py", "*/sub2/*", "*/sub4/**"]
for filepath, matches in matches_to_try:
self.assertMatches(fnm, filepath, matches)

Expand Down

0 comments on commit b2d780d

Please sign in to comment.