Skip tests that need symlink privileges instead of erroring - #2197
Open
Cyrus580529 wants to merge 3 commits into
Open
Skip tests that need symlink privileges instead of erroring#2197Cyrus580529 wants to merge 3 commits into
Cyrus580529 wants to merge 3 commits into
Conversation
Whether a symlink can be created isn't decided by the platform alone: on Windows it needs Developer Mode or SeCreateSymbolicLinkPrivilege.
These called os.symlink unguarded, so on a Windows account without the privilege they errored with WinError 1314 instead of being skipped.
test_index had a private probe and test_refs repeated the same check inline.
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.
Summary
test/test_index.pyintotest/lib/helper.pyassymlinks_supported(), and add arequires_symlinksskip marker beside it.os.symlinkunguarded and error withOSError: [WinError 1314]on a Windows account without Developer Mode orSeCreateSymbolicLinkPrivilege.test_index.py, and the inline try/except plusskipTestintest_refs.py.The tests that were erroring:
test_repo.py::TestRepo::test_ignored_raises_error_w_symlinktest_util.py::TestRmtree::test_avoids_changing_permissions_outside_treetest_installation.py::TestInstallation::test_installationCI doesn't show this because the GitHub Windows runners hold the privilege, so the three run and pass there.
One behaviour note: the probe used to return early on non-Windows, so it never created anything. Now it always creates and removes a symlink in a temporary directory, on every platform.
Validation
Windows 11, Python 3.13, after
./init-tests-after-clone.sh:python -m pytest --ignore=test/performance— before: 6 failed, 711 passed, 47 skipped. After: 3 failed, 711 passed, 50 skipped.test_commit_msg_hook_fail,test_pre_commit_hook_fail, andtest_index_mutation, which passes a POSIX absolute path togit rm.python -m ruff check test/python -m ruff format --check test/