-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Windows test fixes and CI with AppVeyor #1504
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
a57a81e
to
df5c18e
Compare
Waiter depended on a couple of posix tricks. The first was a clever use of os.waitpid(-1, 0) to wait for any spawned processes to return. On Windows, this raises an exception - Windows has no concept of a process group. The second was the use of NamedTempFile(). On anything but Windows, a file can be open for writing and for reading at the same time. This trick actually isn't necessary the way NamedTempFile is used here. It exposes a file-like object pointing to a file already opened in binary mode. All we have to do is seek and read from it.
The only tricky bit of this is renaming python.exe to python2.exe. This is due to util.try_find_python2_interpreter(), which may well need work for Windows since the version symlinks don't exist on Windows.
Currently the Travis CI tests (on Linux) fail, that needs to be addressed. I'll leave this to @ddfisher to review. |
Getting a traceback in the incremental builder:
os.rename cannot replace a file on Windows. Python 3.3 adds os.replace(), a cross-platform function, but it looks like mypy's minimum version is 3.2. There's a TODO in build.py that mentions it may not be atomic, but that's incorrect - it actually fails. Not sure how this should be fixed. |
Support for PY 3.2 will be dropped soon anyway, so you can do os.replace if
it exists else os.rename.
|
Most of these fixes revolve around the path separator and the way Windows handles files and locking. There is one bug fix in here - build.write_cache() was using os.rename to replace a file, which fails on Windows. I was only able to fix that for Python 3.3 and up.
I'm not sure why the type checking works on Python 3.2 after adding os.replace() to typeshed (I put it on a conditional for Python 3.3 or newer) but everything looks good now. Latest Windows build: https://ci.appveyor.com/project/jtatum/mypy/build/1.0.21 There are probably too many Python versions in the matrix - the tests are much slower and AppVeyor doesn't offer concurrency for FOSS projects. |
Conditions aren't implemented yet in mypy. No worries.
…--Guido (mobile)
|
@@ -65,6 +65,8 @@ def parse_test_cases( | |||
tcout = [] # type: List[str] | |||
if i < len(p) and p[i].id == 'out': | |||
tcout = p[i].data | |||
if p[i].arg == 'pathfix': | |||
tcout = [s.replace('/', os.path.sep) for s in tcout] |
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.
Rather than having to remember to add 'pathfix' to tests that happen to have pathnames with slashes in the expected output, maybe you could always fix the path in the text up to the first colon, skipping this completely if the line starts with whitespace or there's whitespace in the stuff before that first colon (or there is no colon)?
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 considered this but was hesitant to add more magic to this code. If that's the preference, I certainly could, though. Do you suppose there are other [out] sections that might be affected by that change? Should that behavior be documented somewhere, maybe in comments in test/data.py?
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.
The only way to be sure is to survey all [out] sections of all test files. Or at least sample a bunch of different ones (some have a different format, the test prints the repr() of some Node).
I just worry that your current approach will mean that every time a new test requires [out pathfix] it will first be committed without the pathfix and then after some time someone will report that it's broken on Windows and someone has to remember how to fix it.
FWIW I need to spend more time reviewing your changes to the code.
|
(I meant to say that I don't have that time right now but I will get back to this later in the week.) |
So this looks fine except I still don't like the idea of having to add "pathfix" to all those tests. Did you find a better way? Would be nice if we could release this next week (just before PyCon). |
Hey, I'm taking over this PR here: #1593. I'm closing this version. Thanks for getting it this far! I'm building on your work and acknowledging it in the commit message. |
I noticed in #1353 that testing for the new parser is needed on Windows. I thought I'd get that started with some CI from AppVeyor. It turned out to be a bit more complicated than that.
This is what the tests look like on Windows: https://ci.appveyor.com/project/jtatum/mypy/build/1.0.16
Still to-do: