tests: checks.{unit,vm-basic,vm-hyprland} + the harness behind them
Wires a `checks` output into the flake, one file per check under checks/, all three asserting docs/CONTRACT.md rather than the implementation: - unit: pytest over tests/unit/ in the build sandbox, against the nix/package.nix build. Refuses an empty suite -- pytest exits 0 when every test was skipped or deselected, so checks/lib/check_report.py parses the JUnit report and fails on zero collected or zero executed. - vm-basic: nixosTest with captureCommand pointed at tests/fake_capture.py, which emits one fixed deterministic PNG. Because the image never changes, "two frames arrived and they are the same bytes" is an assertion about the framing rather than a coincidence. - vm-hyprland: the same machine with no captureCommand override, so grim captures the real compositor. Deliberately impatient -- bounded timeouts, no retry loops, and a full diagnostics dump (compositor log, hyprctl monitors, both journals) before any failure propagates. tests/assert_stream.py is a second, independent reader of the contract: it shares no code with hhstream.client, so a framing bug present in both the server's writer and the shipped client's reader still fails. The unit suite's negative tests use a `rejects` fixture instead of pytest.raises(Exception), which an unimplemented stub's NotImplementedError would otherwise satisfy. Three defects found in code this branch does not own, recorded in README.dev.md rather than worked around: - nix/module.nix has no config side, so neither unit exists and both VM checks fail at their first wait; - services.hyprland-headless-stream.package is declared with no default, against docs/CONTRACT.md; - src/hhstream/*.py is all stubs, so 66 of 70 unit tests fail. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017YXMoCNxzScTaKNr43GQNz
This commit is contained in:
1 parent
c0a59f5673
commit
75a05cd72f
17 files changed
+2131
-2
No files matched your search
@@ -0,0 +1,38 @@
|
||||
"""The parts of the package that are plain constants, checked against the contract.
|
||||
|
||||
These are the only tests here that do not depend on an implementation, which
|
||||
makes them the canary for the `unit` check's own wiring: if they fail, the
|
||||
package is not importable from the build sandbox and nothing else means anything.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import hhstream
|
||||
from hhstream import capture, client, protocol, server
|
||||
|
||||
from conftest import CONTRACT_SOCKET
|
||||
|
||||
|
||||
def test_magic_matches_the_contract():
|
||||
# docs/CONTRACT.md: {"magic":"HHS1", ...}
|
||||
assert hhstream.MAGIC == "HHS1"
|
||||
assert protocol.MAGIC == "HHS1"
|
||||
|
||||
|
||||
def test_default_socket_path_matches_the_contract():
|
||||
assert server.DEFAULT_SOCKET == CONTRACT_SOCKET
|
||||
assert client.DEFAULT_SOCKET == CONTRACT_SOCKET
|
||||
|
||||
|
||||
def test_public_surface_is_present():
|
||||
for name in ("hello", "parse_hello", "frame", "read_frame", "read_hello"):
|
||||
assert callable(getattr(protocol, name)), f"protocol.{name}"
|
||||
assert callable(client.fetch)
|
||||
assert callable(client.main)
|
||||
assert callable(server.main)
|
||||
assert isinstance(server.FrameServer, type)
|
||||
assert isinstance(capture.CommandCapture, type)
|
||||
|
||||
|
||||
def test_version_is_the_packaged_version():
|
||||
assert hhstream.__version__ == "0.1.0"
|
||||
Reference in new issue
Block a user