-
Notifications
You must be signed in to change notification settings - Fork 45
fix: resolve WinError 32 during sparse-checkout fallback on Windows #235
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |||||||||||
|
|
||||||||||||
| import os | ||||||||||||
| import pytest | ||||||||||||
| import stat | ||||||||||||
| import tempfile | ||||||||||||
| import shutil | ||||||||||||
| from pathlib import Path | ||||||||||||
|
|
@@ -998,5 +999,132 @@ def setup_subdir(*args, **kwargs): | |||||||||||
| downloader.download_subdirectory_package(dep_ref, target) | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| class TestWindowsCleanupHelpers: | ||||||||||||
| """Test _rmtree and _close_repo helpers for Windows compatibility.""" | ||||||||||||
|
|
||||||||||||
| def test_rmtree_removes_normal_directory(self): | ||||||||||||
| from apm_cli.deps.github_downloader import _rmtree | ||||||||||||
| d = Path(tempfile.mkdtemp()) | ||||||||||||
| (d / "file.txt").write_text("hello") | ||||||||||||
| _rmtree(d) | ||||||||||||
| assert not d.exists() | ||||||||||||
|
|
||||||||||||
| def test_rmtree_handles_readonly_files(self): | ||||||||||||
| from apm_cli.deps.github_downloader import _rmtree | ||||||||||||
| d = Path(tempfile.mkdtemp()) | ||||||||||||
| f = d / "readonly.txt" | ||||||||||||
| f.write_text("locked") | ||||||||||||
| os.chmod(str(f), stat.S_IREAD) | ||||||||||||
| _rmtree(d) | ||||||||||||
| assert not d.exists() | ||||||||||||
|
|
||||||||||||
| def test_close_repo_none_is_safe(self): | ||||||||||||
| from apm_cli.deps.github_downloader import _close_repo | ||||||||||||
| # Must not raise when passed None | ||||||||||||
| _close_repo(None) | ||||||||||||
|
|
||||||||||||
| def test_close_repo_releases_gitpython_handles(self): | ||||||||||||
| from apm_cli.deps.github_downloader import _close_repo | ||||||||||||
| repo = MagicMock() | ||||||||||||
| _close_repo(repo) | ||||||||||||
| repo.git.clear_cache.assert_called_once() | ||||||||||||
| repo.close.assert_called_once() | ||||||||||||
|
|
||||||||||||
| def test_close_repo_swallows_exceptions(self): | ||||||||||||
| from apm_cli.deps.github_downloader import _close_repo | ||||||||||||
| repo = MagicMock() | ||||||||||||
| repo.git.clear_cache.side_effect = RuntimeError("git gone") | ||||||||||||
| # Must not propagate | ||||||||||||
| _close_repo(repo) | ||||||||||||
|
||||||||||||
| _close_repo(repo) | |
| _close_repo(repo) | |
| # Even if clear_cache fails, we must still attempt it and close the repo | |
| repo.git.clear_cache.assert_called_once() | |
| repo.close.assert_called_once() |
Uh oh!
There was an error while loading. Please reload this page.