-
-
Notifications
You must be signed in to change notification settings - Fork 954
Test native Windows on CI #1745
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
2fd79f4
Add native Windows test jobs to CI matrix
EliahKagan 6e477e3
Add xfail marks for IndexFile.from_tree failures
EliahKagan cd9d7a9
Mark test_clone_command_injection xfail on Windows
EliahKagan f72e282
Mark test_diff_submodule xfail on Windows
EliahKagan 42a3d74
Mark TestSubmodule.test_rename xfail on Windows
EliahKagan 4abab92
Mark test_conditional_includes_from_git_dir xfail on Windows
EliahKagan 799c853
Improve ordering/grouping of a few imports
EliahKagan b284ad7
Mark test_create_remote_unsafe_url_allowed xfail on Windows
EliahKagan 61d1fba
Mark unsafe-options "allowed" tests xfail on Windows
EliahKagan ad07ecb
Show PATH on CI
EliahKagan 2784e40
Show bash and other WSL-relevant info but not PATH
EliahKagan 9717b8d
Install WSL system on CI for hook tests
EliahKagan 5d11394
Fix and expand bash.exe xfail marks on hook tests
EliahKagan b215357
Simplify/clarify bash.exe check for hook tests; do it only once
EliahKagan cabb572
Temporarily don't install WSL system to test xfail
EliahKagan 2875ffa
Put back WSL on Windows CI; pare down debug info
EliahKagan 0f8cd4c
Treat XPASS status as a test failure
EliahKagan 82c361e
Correct TestSubmodule.test_rename xfail condition
EliahKagan 0ae5dd1
Revert "Treat XPASS status as a test failure"
EliahKagan 0b7ee17
Refine TestSubmodule.test_rename xfail condition
EliahKagan 8621e89
Reword comment in _WinBashStatus.check for clarity
EliahKagan 7ff3cee
Make _WinBashStatus instances carry all their info
EliahKagan d5ed266
Use bytes in bash.exe check; retest no-distro case
EliahKagan 496acaa
Handle multiple encodings for WSL error messages
EliahKagan d779a75
Don't assume WSL-related bash.exe error is English
EliahKagan 9ac2438
Handle encodings better; make the sum type "public"
EliahKagan b07e5c7
Put back WSL on Windows CI
EliahKagan 3303c74
Improve readability of WinBashStatus class
EliahKagan e00fffc
Shorten comments on _decode steps
EliahKagan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix and expand bash.exe xfail marks on hook tests
881456b (#1679) expanded the use of shutil.which in test_index.py to attempt to mark test_commit_msg_hook_success xfail when bash.exe is a WSL bash wrapper in System32 (because that test currently is not passing when the hook is run via bash in a WSL system, which the WSL bash.exe wraps). But this was not reliable, due to significant differences between shell and non-shell search behavior for executable commands on Windows. As the new docstring notes, lookup due to Popen generally checks System32 before going through directories in PATH, as this is how CreateProcessW behaves. - https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessw - python/cpython#91558 (comment) The technique I had used in 881456b also had the shortcoming of assuming that a bash.exe in System32 was the WSL wrapper. But such a file may exist on some systems without WSL, and be a bash interpreter unrelated to WSL that may be able to run hooks. In addition, one common situation, which was the case on CI before a step to install a WSL distribution was added, is that WSL is present but no WSL distributions are installed. In that situation bash.exe is found in System32, but it can't be used to run any hooks, because there's no actual system with a bash in it to wrap. This was not covered before. Unlike some conditions that prevent a WSL system from being used, such as resource exhaustion blocking it from being started, the absence of a WSL system should probably not fail the pytest run, for the same reason as we are trying not to have the complete *absence* of bash.exe fail the pytest run. Both conditions should be xfail. Fortunately, the error message when no distribution exists is distinctive and can be checked for. There is probably no correct and reasonable way to check LBYL-style which executable file bash.exe resolves to by using shutil.which, due to shutil.which and subprocess.Popen's differing seach orders and other subtleties. So this adds code to do it EAFP-style using subprocess.run (which itself uses Popen, so giving the same CreateProcessW behavior). It tries to run a command with bash.exe whose output pretty reliably shows if the system is WSL or not. We may fail to get to the point of running that command at all, if bash.exe is not usable, in which case the failure's details tell us if bash.exe is absent (xfail), present as the WSL wrapper with no WSL systems (xfail), or has some other error (not xfail, so the user can become aware of and proably fix the problem). If we do get to that point, then a file that is almost always present on both WSL 1 and WSL 2 systems and almost always absent on any other system is checked for, to distinguish whether the working bash shell operates in a WSL system, or outside any such system as e.g. Git Bash does. See https://superuser.com/a/1749811 on various techniques for checking for WSL, including the /proc/sys/fs/binfmt_misc/WSLInterop technique used here (which seems overall may be the most reliable). Although the Windows CI runners have Git Bash, and this is even the bash.exe that appears first in PATH (giving rise to the problem with shutil.which detailed above), it would be a bit awkward to test the behavior when Git Bash is actually used to run hooks on CI, because of how Popen selects the System32 bash.exe first, whether or not any WSL distribution is present. However, local testing shows that when Git Bash's bash.exe is selected, all four hook tests in the module pass, both before and after this change, and furthermore that bash.exe is correctly detected as "native", continuing to avoid an erroneous xfail mark in that case.
- Loading branch information
commit 5d113942786b2cc86f5fd7bb228f9f75c8c78beb
There are no files selected for viewing
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
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.