-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bump coverage.py
to v7.3.0 in ansible-test
#81077
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@webknjaz The changes looked correct, but I decided to test the glob matching to be sure. At first I tried reverting the glob portion of your changes in this PR -- yet code coverage was still reported. Then I tried using the API directly and I'm seeing the old behavior:
from coverage.files import GlobMatcher
print(GlobMatcher('/hello/*').match('/hello/too/deep/to/match.py'))
I'd expect that not to match, since I didn't use **
, but it does. Can you confirm that glob matching is (or is not) working as documented?
Also, once we've merged this PR with whatever coverage version we pick, we'll want to update the spare-tire repo: We should be able to just replace |
@mattclay I think you're initializing it wrong. Look at the initializer signature: class GlobMatcher:
"""A matcher for files by file name pattern."""
def __init__(self, pats: Iterable[str], name: str = "unknown") -> None:
self.pats = list(pats)
self.re = globs_to_regex(self.pats, case_insensitive=env.WINDOWS)
self.name = name It expects an iterable of strings and applies In [18]: list('/hello/*')
Out[18]: ['/', 'h', 'e', 'l', 'l', 'o', '/', '*'] Unsurprisingly, it doesn't do what you meant. Wrapping it into a non-string iterable should fix that, but it still matches: In [19]: GlobMatcher('/hello/*').match('/hello/too/deep/to/match.py')
Out[19]: True
In [20]: GlobMatcher(('/hello/*', )).match('/hello/too/deep/to/match.py')
Out[20]: True These are the internal regexps it creates out of the args: In [27]: GlobMatcher('/hello/*').re
Out[27]:
re.compile(r'(?:(?:[/\\])|(?:(.*[/\\])?h)|(?:(.*[/\\])?e)|(?:(.*[/\\])?l)|(?:(.*[/\\])?l)|(?:(.*[/\\])?o)|(?:[/\\])|(?:(.*[/\\])?[^/\\]*))\Z',
re.UNICODE)
In [28]: GlobMatcher(('/hello/*', )).re
Out[28]: re.compile(r'(?:[/\\]hello[/\\].*)\Z', re.UNICODE) Need to look deeper... |
It looks like In [31]: GlobMatcher(('/hello/*/thing/', )).re
Out[31]: re.compile(r'(?:[/\\]hello[/\\][^/\\]*[/\\]thing[/\\])\Z', re.UNICODE)
In [32]: GlobMatcher(('/hello/*/', )).re
Out[32]: re.compile(r'(?:[/\\]hello[/\\][^/\\]*[/\\])\Z', re.UNICODE)
In [33]: GlobMatcher(('/hello/*', )).re
Out[33]: re.compile(r'(?:[/\\]hello[/\\].*)\Z', re.UNICODE)
In [34]: GlobMatcher(('/hello/*/thing/', )).match('/hello/too/deep/to/match.py')
Out[34]: False
In [35]: GlobMatcher(('/hello/*/too/', )).match('/hello/too/deep/to/match.py')
Out[35]: False
In [36]: GlobMatcher(('/hello/*/deep/', )).match('/hello/too/deep/to/match.py')
Out[36]: False
In [37]: GlobMatcher(('/hello/*/deep/*', )).match('/hello/too/deep/to/match.py')
Out[37]: True
In [38]: GlobMatcher(('/hello/*/', )).match('/hello/too/deep/to/match.py')
Out[38]: False
In [39]: GlobMatcher(('/hello/*', )).match('/hello/too/deep/to/match.py')
Out[39]: True
In [40]: GlobMatcher(('/hello/*', )).match('/hello/too/')
Out[40]: True
In [41]: GlobMatcher(('/hello/*/', )).match('/hello/too/')
Out[41]: True
In [42]: GlobMatcher(('/hello/*/', )).match('/hello/too/deep')
Out[42]: False
In [43]: GlobMatcher(('/hello/*/', )).match('/hello/too/deep/')
Out[43]: False It is unclear why this specific corner case was added, as it is not documented explicitly, nor does the commit add any tests for this case. It might be intended or a bug, there's no way to deduce it w/o asking.. |
@mattclay I submitted nedbat/coveragepy#1650 — let's see if that gets us the desired behavior in the end. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there hasn't been any movement on nedbat/coveragepy#1650, I think we should move on without waiting for that. That appears to be safe to do, since the only issue seems to be that /*
counts as /**
, correct?
Yes, and I think that sticking |
Yes, it does appear to work fine with the older versions, and even though it isn't needed in all cases for the current versions, it does match the documented behavior. So we should be OK regardless of whether or not the issue we discovered is resolved. |
82c33cd
to
0887f0c
Compare
Interestingly, I haven't found any changelog fragments coupled with the previous version bumps — I was hoping for an example of what could be expected. |
0887f0c
to
ba1ba9a
Compare
*/pytest | ||
*/AnsiballZ_*.py | ||
*/test/results/* | ||
**/python*/dist-packages/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mattclay should we revert these after all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to confirm, the new **
behavior is only for matching in the middle of a path? The */
and /*
matches at the start and end of a path continue to work without **
?
If that's the case, then yes, we should revert the path changes, since it seems the coverage docs will be updated, rather than the implementation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's correct. I've been thinking of documenting this upstream, since it's unlikely that Ned will accept the original change I offered.
The versions supported haven't changed since 2.14, when support for multiple coverage versions was first added in #77578. The version currently in use was set before the 2.14.0 release in #78945, so it was essentially already covered by the existing changelog entry. |
FTR the docs are being improved here: nedbat/coveragepy#1675. In case, you have an opinion. |
Co-authored-by: Matt Clay <matt@mystile.com>
ba1ba9a
to
822fe91
Compare
@mattclay this is ready! |
/azp run |
Pipelines were unable to run due to time out waiting for the pull request to finish merging. |
This reverts commit c59bcbe. ci_complete ci_coverage
As of coverage 7.1.0, files without arcs are not generated. To work around this, an empty (0, 0) arc is used for each file instead. This is a follow-up to ansible#81077 ci_coverage ci_complete
As of coverage 7.1.0, files without arcs are not generated. To work around this, an empty (0, 0) arc is used for each file instead. This is a follow-up to #81077 ci_coverage ci_complete
This patch upgrades the
coverage.py
version used under Python 3.8 through 3.12.It also upgrades the path patterns in the generated configs according to the changes
in v7.0.0b1 of said library as it replaced the matching method from
fnmatch
toglob
[1][2].Resolves #80427
SUMMARY
^ $sbj ^
ISSUE TYPE
COMPONENT NAME
ansible-test
ADDITIONAL INFORMATION
N/A