diff --git a/coverage/files.py b/coverage/files.py index aade31afd..2daa4a59e 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -316,7 +316,7 @@ def sep(s: str) -> str: (r"\*\*+[^/]+", None), # Can't have **x (r"\*\*/\*\*", None), # Can't have **/** (r"^\*+/", r"(.*[/\\\\])?"), # ^*/ matches any prefix-slash, or nothing. - (r"/\*+$", r"[/\\\\].*"), # /*$ matches any slash-suffix. + (r"/\*\*+$", r"[/\\\\].*"), # /**$ matches any slash-suffix. (r"\*\*/", r"(.*[/\\\\])?"), # **/ matches any subdirs, including none (r"/", r"[/\\\\]"), # / matches either slash or backslash (r"\*", r"[^/\\\\]*"), # * matches any number of non slash-likes diff --git a/tests/test_files.py b/tests/test_files.py index 7424775b3..9420eeb05 100644 --- a/tests/test_files.py +++ b/tests/test_files.py @@ -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) diff --git a/tests/test_report.py b/tests/test_report.py index 51a4fc683..316472537 100644 --- a/tests/test_report.py +++ b/tests/test_report.py @@ -107,7 +107,7 @@ def test_report_omitting(self) -> None: self.make_mycode() cov = coverage.Coverage() self.start_import_stop(cov, "mycode") - report = self.get_report(cov, omit=[f"{TESTS_DIR}/*", "*/site-packages/*"]) + report = self.get_report(cov, omit=[f"{TESTS_DIR}/**", "*/site-packages/**"]) # Name Stmts Miss Cover # -------------------------------