From ee6506f08e5de7e568751f78e8be82fc2a102ffe Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Wed, 19 Apr 2023 11:23:12 -0400 Subject: fix: specific files to include/omit should match even with relative files #1604. --- CHANGES.rst | 6 ++++++ coverage/files.py | 5 ++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index a001a9e6..377cabc1 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -20,6 +20,10 @@ development at the same time, such as 4.5.x and 5.0. Unreleased ---------- +- Fix: with ``relative_files = true``, specifying a specific file to include or + omit wouldn't work correctly (`issue 1604`_). This is now fixed, with + testing help by `Marc Gibbons `_. + - Fix: the XML report would have an incorrect ```` element when using relative files and the source option ended with a slash (`issue 1541`_). This is now fixed, thanks to `Kevin Brown-Silva `_. @@ -35,7 +39,9 @@ Unreleased .. _issue 1523: https://github.com/nedbat/coveragepy/issues/1523 .. _issue 1541: https://github.com/nedbat/coveragepy/issues/1541 +.. _issue 1604: https://github.com/nedbat/coveragepy/issues/1604 .. _pull 1608: https://github.com/nedbat/coveragepy/pull/1608 +.. _pull 1609: https://github.com/nedbat/coveragepy/pull/1609 .. _pull 1610: https://github.com/nedbat/coveragepy/pull/1610 .. _pull 1613: https://github.com/nedbat/coveragepy/pull/1613 diff --git a/coverage/files.py b/coverage/files.py index 2a117734..925d5772 100644 --- a/coverage/files.py +++ b/coverage/files.py @@ -209,9 +209,8 @@ def prep_patterns(patterns: Iterable[str]) -> List[str]: """ prepped = [] for p in patterns or []: - if p.startswith(("*", "?")): - prepped.append(p) - else: + prepped.append(p) + if not p.startswith(("*", "?")): prepped.append(abs_file(p)) return prepped -- cgit v1.2.1