Fix broken tests on Windows due to EOF error and other minor bugs#543
Merged
justinmk merged 4 commits intoneovim:masterfrom Oct 16, 2023
Merged
Fix broken tests on Windows due to EOF error and other minor bugs#543justinmk merged 4 commits intoneovim:masterfrom
justinmk merged 4 commits intoneovim:masterfrom
Conversation
Member
Author
|
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 |
This was referenced Oct 15, 2023
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'
```
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🎉✅ 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.