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).
This commit is contained in:
ColrWei
2026-09-11 13:06:57 +08:00
committed by Teknium
parent d47df6ea00
commit 80ea4cbde0
3 changed files with 13 additions and 2 deletions

View File

@@ -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:

View File

@@ -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()

View File

@@ -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