-
Notifications
You must be signed in to change notification settings - Fork 120
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
Fix broken tests on Windows due to EOF error and other minor bugs #543
Conversation
I dropped one commit (fix: monkey-patch _ProactorBasePipeTransport to suppress warning) from this PR. Tests are all passing anyway (but with many warnings). The warnings on |
9475be5
to
9e3d958
Compare
Problem: Across unit tests, custom path_hook reigstered globally by ScriptHost globally was not being cleared up properly. This results in leakage of internal resources and dangling access to them (such as asyncio event loops that was already closed and no longer valid in other test case instances). More specifically, the asyncio EventLoop were never closed, which can result in "Event loop is closed" errors upon garbage collection of internal transport objects (during cleaning up pytest sessions). Solution: (1) Always call ScriptHost.teardown() when done using it. (2) Make sure all internal resources (event loops, transport channels, etc.) are closed by closing the embedded neovim instance.
Problem: An EOF error happens when creating a subprocess Nvim instance on Windows. All CI tests are failing, and `attach('child', ...)` cannot be run. Solution: Ignore pipe_connection_lost error, and do not close the asyncio event loop. Since embedded nvim only expects to use stdin and stdout only as a msgpack-RPC channel, it's fine to ignore broken pipes on the stderr. Fixes neovim#505
Problem: ``` > os.unlink(fname) E PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\tmpugb75_rw' ```
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.
Beautiful, thank you!
πβ TESTS on WINDOWS ARE NOW ALL GREEN β π
Note: This PR consists of several commits and bugfixes, each of which is all required to fix the broken tests on windows platform for such a long time. I would like to request @justinmk that please merge this PR without squashing (either merge commit or rebasing), retaining all the individual commits.
fix: EOF error on piped stderr being closed on Windows
Most importantly, this PR should fix #505. Pipe (subprocess) based pynvim was broken since neovim 0.5.0, probably due to neovim/neovim@c86d5fa (neovim/neovim#11390): on Windows, stderr is closed for an embedded nvim.
See the commit message for more details.
fix: do not leak resources across tests so as to prevent side effects
See the commit message for more details. asyncio event loops were not closing properly during tests, and were leaking in subsequent EventLoop, Session, Nvim instances.