From 80ea4cbde0c1f292cd0dcdb85522a0936247a4a5 Mon Sep 17 00:00:00 2001 From: ColrWei <4578560@qq.com> Date: Fri, 11 Sep 2026 13:06:57 +0800 Subject: [PATCH] fix(tests): skip POSIX-only and symlink tests on Windows CI Five tests were silently failing on the Windows CI job because they either required a Linux/macOS runtime or created symlinks (which the default Windows user cannot do without Developer Mode). Mark them with the project's existing linux_only / require_symlinks markers so CI on Windows skips them cleanly instead of reporting red: * TestPosixNoOp, test_noop_on_posix, test_no_hermes_home_returns_native -> @pytest.mark.linux_only (the asserts only make sense on POSIX where '~/.hermes' is the natural HERMES_HOME fallback). * test_atomic_replace_copy_fallback_preserves_symlink, test_symlinked_target_survives_a_contended_rename -> @pytest.mark.require_symlinks (matches the pattern already used by sibling tests in the same file). For the two symlink tests in test_hermes_constants.py that weren't covered by require_symlinks, wrap the symlink_to() call in a try/except(OSError, NotImplementedError) -> pytest.skip() so a host without symlink privilege still skips instead of erroring out. No production code touched. Verified locally on win32 Python 3.11.9: 88 passed, 25 skipped, 0 failed across the three files (down from 7 failed, 88 passed). --- tests/test_atomic_replace_symlinks.py | 2 ++ tests/test_hermes_bootstrap.py | 2 ++ tests/test_hermes_constants.py | 11 +++++++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/test_atomic_replace_symlinks.py b/tests/test_atomic_replace_symlinks.py index 42c8556889..797d2b3a12 100644 --- a/tests/test_atomic_replace_symlinks.py +++ b/tests/test_atomic_replace_symlinks.py @@ -224,6 +224,7 @@ def test_atomic_replace_broken_symlink_creates_target(tmp_path: Path) -> None: +@pytest.mark.require_symlinks def test_atomic_replace_copy_fallback_preserves_symlink( tmp_path: Path, monkeypatch: pytest.MonkeyPatch ) -> None: @@ -506,6 +507,7 @@ def test_in_place_rewrite_never_exposes_a_truncated_file( assert observed == [5000] +@pytest.mark.require_symlinks def test_symlinked_target_survives_a_contended_rename( tmp_path: Path, monkeypatch: pytest.MonkeyPatch, fast_replace_retries: None ) -> None: diff --git a/tests/test_hermes_bootstrap.py b/tests/test_hermes_bootstrap.py index b95b50d9ad..a97b05d128 100644 --- a/tests/test_hermes_bootstrap.py +++ b/tests/test_hermes_bootstrap.py @@ -120,6 +120,7 @@ class TestUserOptOut: +@pytest.mark.linux_only class TestPosixNoOp: """POSIX: zero behavior change. We don't touch LANG, LC_*, or any stdio. The goal is that Linux/macOS behave identically before and @@ -336,6 +337,7 @@ class TestHardenImportPath: class TestSuppressPlatformVerConsole: """suppress_platform_ver_console: stub applied on Windows, no-op on POSIX.""" + @pytest.mark.linux_only def test_noop_on_posix(self): import platform hb = _fresh_import() diff --git a/tests/test_hermes_constants.py b/tests/test_hermes_constants.py index 86684fc0ea..093bc9ad60 100644 --- a/tests/test_hermes_constants.py +++ b/tests/test_hermes_constants.py @@ -33,6 +33,7 @@ from hermes_constants import ( class TestGetDefaultHermesRoot: """Tests for get_default_hermes_root() — Docker/custom deployment awareness.""" + @pytest.mark.linux_only def test_no_hermes_home_returns_native(self, tmp_path, monkeypatch): """When HERMES_HOME is not set, returns ~/.hermes.""" monkeypatch.delenv("HERMES_HOME", raising=False) @@ -759,7 +760,10 @@ class TestGetHermesDir: """ self._set_home(tmp_path, monkeypatch) legacy = tmp_path / "pairing" - legacy.symlink_to(tmp_path / "does-not-exist") + try: + legacy.symlink_to(tmp_path / "does-not-exist") + except (OSError, NotImplementedError) as exc: + pytest.skip(f"Symlink not supported on this platform/permission: {exc}") new = tmp_path / "platforms" / "pairing" new.mkdir(parents=True) (new / "discord-approved.json").write_text("[]") @@ -773,7 +777,10 @@ class TestGetHermesDir: real.mkdir() (real / "cached.png").write_bytes(b"x") legacy = tmp_path / "image_cache" - legacy.symlink_to(real) + try: + legacy.symlink_to(real) + except (OSError, NotImplementedError) as exc: + pytest.skip(f"Symlink not supported on this platform/permission: {exc}") result = get_hermes_dir("cache/images", "image_cache") assert result == legacy