30da5d0a89
many tests patched sys.platform or a module's _IS_WINDOWS flag, then ran on linux ci. the patch selects the branch under test, but the host does not have the behavior the branch exists for. the test proves the patch, not the platform. some gated assertions never ran on any host. this commit adds three markers: linux_only, macos_only, windows_only. a conftest hook skips a marked test on the other hosts, with a clear reason. no test fakes a host now. two documented fakes remain (android/termux, freebsd) because no ci runner exists for them. each fake site got one of four treatments: - gate it: the real host supplies the platform; mocks cover real dependencies only, never host identity - patch the module's own probe when the subject is the probe's consumer - assert against the real host when the fake stood in for any non-x host - delete the patch when it set the value the host already has bare skipif(sys.platform != ...) guards became markers too. the lane model skips these on linux and never imports them on windows, so they ran on no host. platform parametrize tables are now one marked test per os. running on real hosts found real errors: a chrome-sandbox failure in test_gui_command that main hides, and two windows failures fixed here. the agents.md testing section now documents the policy.
60 lines
2.3 KiB
Python
60 lines
2.3 KiB
Python
"""Host-specific gating in ``hermes_cli.gateway._all_platforms()``.
|
|
|
|
Some messaging platforms can't function on every host. The gate lives
|
|
in one place — ``_all_platforms()`` — so the setup wizard, the curses
|
|
gateway-config menu, and any future picker all see the same filtered
|
|
list.
|
|
|
|
Currently:
|
|
- Matrix is hidden on Windows. The ``[matrix]`` extra pulls
|
|
``mautrix[encryption]`` -> ``python-olm``, which has no Windows wheel
|
|
and needs ``make`` + libolm to build from sdist. There's no native
|
|
Windows path that works.
|
|
"""
|
|
|
|
import pytest
|
|
|
|
|
|
class TestMatrixHiddenOnWindows:
|
|
@pytest.mark.linux_only
|
|
def test_matrix_present_on_linux(self):
|
|
"""Sanity: matrix is still in the picker on Linux.
|
|
|
|
Linux-gated because the assertion is the negative of the Windows
|
|
gate — it only means anything when the host really is not Windows.
|
|
"""
|
|
import hermes_cli.gateway as gateway_mod
|
|
|
|
platforms = gateway_mod._all_platforms()
|
|
keys = {p["key"] for p in platforms}
|
|
assert "matrix" in keys, "matrix must be available on Linux"
|
|
|
|
@pytest.mark.windows_only
|
|
def test_matrix_absent_on_windows(self):
|
|
"""The gate itself: matrix must be dropped on a real Windows host.
|
|
|
|
A patched ``sys.platform`` proved only that the ``if`` branch runs;
|
|
on native Windows this also proves the picker the user actually sees
|
|
omits the platform whose dependency cannot build here.
|
|
"""
|
|
import hermes_cli.gateway as gateway_mod
|
|
|
|
platforms = gateway_mod._all_platforms()
|
|
keys = {p["key"] for p in platforms}
|
|
assert "matrix" not in keys, "matrix must be hidden on Windows"
|
|
|
|
@pytest.mark.windows_only
|
|
def test_other_platforms_unaffected_on_windows(self):
|
|
"""Gating must only drop matrix, not collateral damage."""
|
|
import hermes_cli.gateway as gateway_mod
|
|
|
|
platforms = gateway_mod._all_platforms()
|
|
keys = {p["key"] for p in platforms}
|
|
# A representative sample of platforms that have no Windows
|
|
# blockers — picker should still surface them.
|
|
for must_have in ("telegram", "discord", "slack", "mattermost"):
|
|
assert must_have in keys, (
|
|
f"{must_have} disappeared from Windows picker — gate is "
|
|
"over-filtering"
|
|
)
|