-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Fixes to reports.py -- don't crash on control characters, ensure directories earlier #5885
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
Conversation
…ctories earlier Fixes python#5884
I don't understand why the tests fail on Windows only, but clearly it's got something to do with my moving around the |
74ae0d7
to
1c9f008
Compare
1c9f008
to
7723238
Compare
At last! Because of my refactor, the I'll try to fix this too. |
@msullivan This is now officially ready for review. I did expand a bit on the original issue (control characters) but I think the report generator and the test framework are a bit better now. |
@@ -418,6 +415,10 @@ def __init__(self, reports: Reports, output_dir: str) -> None: | |||
self.last_xml = None # type: Optional[Any] | |||
self.files = [] # type: List[FileInfo] | |||
|
|||
# XML doesn't like control characters, but they are sometimes | |||
# legal in source code (e.g. comments, string literals). | |||
control_fixer = str.maketrans(''.join(chr(i) for i in range(32)), '?' * 32) |
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.
I didn't know this function!
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.
Seems good. Why didn't the thing cause trouble before?
A comment containing an odd control character was checked into our S code base last week. I fixed the test harness because I had a hell of a time debugging why the AppVeyor tests were failing (apparently you can't have a directory named |
Ah, Windows doesn't allow less than or greater than in file paths. I am surprised that the tests didn't fail once there was an attempt to create the file however... |
That's why I made the changes to testcmdline.py. It runs mypy in a subprocess, and the subprocess was printing a traceback. But there was logic in testcmdline.py that ignored all output (and the exit status) if at least one output file was expected (i.e. one or more I fixed it so it will now fail loudly and report the traceback. |
Fixes #5884 (both parts).