fix: make the repository pre-commit checks portable on Windows

Use the hook environment’s Python interpreter and select the supported process, terminal, and locking APIs at their platform boundaries. Keep all existing hook checks enabled and fix the tracked SVG EOF that fails a clean all-files run.
This commit is contained in:
LIziak112
2026-11-25 20:35:27 +08:00
parent 14796c70f6
commit 257c5e62dc
11 changed files with 29 additions and 17 deletions

View File

@@ -20,7 +20,8 @@ def test_cleanup_rechecks_group_after_permission_race(monkeypatch, group_exists)
raise PermissionError("group changed during signal")
raise ProcessLookupError("group already reaped")
monkeypatch.setattr(process, "os", SimpleNamespace(name="posix", killpg=killpg))
monkeypatch.setattr(process, "sys", SimpleNamespace(platform="linux"))
monkeypatch.setattr(process, "os", SimpleNamespace(killpg=killpg))
# The POSIX branch is simulated on every OS; Windows has no SIGKILL.
monkeypatch.setattr(process.signal, "SIGKILL", 9, raising=False)
monkeypatch.setattr(process.time, "sleep", lambda _: None)
@@ -38,7 +39,7 @@ def test_windows_cleanup_targets_the_entire_owned_tree(monkeypatch, returncode):
from deeptutor.runtime import process
calls = []
monkeypatch.setattr(process, "os", SimpleNamespace(name="nt"))
monkeypatch.setattr(process, "sys", SimpleNamespace(platform="win32"))
def run(argv, **kwargs):
calls.append((argv, kwargs))