Skip to content

Commit

Permalink
fix: don't forbid plus signs in file names. #1513
Browse files Browse the repository at this point in the history
  • Loading branch information
nedbat committed Dec 23, 2022
1 parent 31513b4 commit 152cdc7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES.rst
Expand Up @@ -20,9 +20,13 @@ development at the same time, such as 4.5.x and 5.0.
Unreleased
----------

- File pattern rules were too strict, forbidding plus signs and curly braces in
directory and file names. This is now fixed, closing `issue 1513`_.

- The PyPy wheel now installs on PyPy 3.7, 3.8, and 3.9, closing `issue 1510`_.

.. _issue 1510: https://github.com/nedbat/coveragepy/issues/1510
.. _issue 1513: https://github.com/nedbat/coveragepy/issues/1513


.. _changes_7-0-0:
Expand Down
2 changes: 1 addition & 1 deletion coverage/files.py
Expand Up @@ -325,7 +325,7 @@ def sep(s):
(r"\?", r"[^/\\\\]"), # ? matches one non slash-like
(r"\[.*?\]", r"\g<0>"), # [a-f] matches [a-f]
(r"[a-zA-Z0-9_-]+", r"\g<0>"), # word chars match themselves
(r"[\[\]+{}]", None), # Can't have regex special chars
(r"[\[\]]", None), # Can't have single square brackets
(r".", r"\\\g<0>"), # Anything else is escaped to be safe
]]

Expand Down
10 changes: 8 additions & 2 deletions tests/test_files.py
Expand Up @@ -230,10 +230,18 @@ def globs_to_regex_params(
matches=["foo", "hello/foo", "hi/there/foo"],
nomatches=["foob", "hello/foob", "hello/Foo"],
),
globs_to_regex_params(
["a+b/foo*", "x{y}z/foo*"],
matches=["a+b/foo", "a+b/foobar", "x{y}z/foobar"],
nomatches=["aab/foo", "ab/foo", "xyz/foo"],
),
]))
)
def test_globs_to_regex(patterns, case_insensitive, partial, text, result):
regex = globs_to_regex(patterns, case_insensitive=case_insensitive, partial=partial)
print(patterns)
print(regex)
print(text)
assert bool(regex.match(text)) == result


Expand All @@ -243,8 +251,6 @@ def test_globs_to_regex(patterns, case_insensitive, partial, text, result):
("*****/foo.py", "*****"),
("Hello]there", "]"),
("Hello[there", "["),
("Hello+there", "+"),
("{a,b}c", "{"),
("x/a**/b.py", "a**"),
("x/abcd**/b.py", "abcd**"),
("x/**a/b.py", "**a"),
Expand Down

0 comments on commit 152cdc7

Please sign in to comment.