test: minor fixes & improvements for files linter test#21873
Merged
maflcko merged 1 commit intobitcoin:masterfrom May 7, 2021
Merged
test: minor fixes & improvements for files linter test#21873maflcko merged 1 commit intobitcoin:masterfrom
maflcko merged 1 commit intobitcoin:masterfrom
Conversation
Updates the lint-files.py lint test: * Use a context manager when opening files, so that files are closed. * Use the -z flag when shelling out to git ls-files so that we can catch newlines and other weird control characters in filenames
windsok
commented
May 7, 2021
| if not filename_regex.match(filename): | ||
| print( | ||
| f"""File "{filename}" does not not match the allowed filename regexp ('{ALLOWED_FILENAME_REGEXP}').""" | ||
| f"""File {repr(filename)} does not not match the allowed filename regexp ('{ALLOWED_FILENAME_REGEXP}').""" |
Contributor
Author
There was a problem hiding this comment.
This change is to ensure any unusual characters are printable in the test log.
https://stackoverflow.com/a/31624058
https://docs.python.org/3/library/functions.html#repr
Member
|
cr ACK 2227fc4 |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Couple of minor fixes & improvements for files linter test added in #21740
Use a context manager when opening files, so that files are closed are we are done with them
Use the
-zflag when shelling out togit ls-filesso that we can catch newlines and other weird control characters in filenames.From the
git ls-filesmanpage: