101 unit tests under `tests/unit/` and one new VM check. The unit suite's subject is the only thing this layer decides: the argv list. `mcp_fake.FakeCli` is a recording stand-in put where the CLI goes, so every test can assert on the exact argv a tool handed over -- the `=` form of each flag, the `--` before each positional, the omission of a flag the caller did not give. Three tests drive the **real** entry point against a control socket that does not exist, which proves the dispatch, the capture and the exit-code mapping against the CLI's actual parser with no daemon standing up: argparse's exit 2 for a bad `--button`, exit 5 for the unreachable broker, exit 9 for a gesture with no lease. `test_mcp_server.py` imports the MCP SDK unconditionally and runs the server in process over the SDK's memory transport. It is not allowed to skip: the tool table is stdlib and tested without the SDK, but whether every schema validates and every name is one the specification allows is a question only the SDK can answer, and a file that skipped when it was absent would be green in exactly the build where that mattered. `checks/unit.nix` therefore puts `mcp` in the test environment and `hhstream-mcp` on PYTHONPATH beside `hhstream`. `checks/vm-mcp.nix` boots the session machine with `mcp.enable = true` and drives the real binary over a real pipe with `checks/lib/mcp_client.py` -- raw JSON-RPC, deliberately not the SDK's client, for the reason `tests/assert_stream.py` is a second implementation of the frame contract. It asserts the handshake, the 26-tool listing with its annotations and its two rules, a call that reaches the live broker, `shot` as image content, the lease granted/used/returned against the real driver, and exits 9 and 3 arriving as tool errors. The geometry assertion in that check is one it got wrong first time and now records: the published frame is 2560x720 on a guest configured for 1280x720, because the publisher's default capture takes the whole compositor layout and a session's container is a second output beside the main one. `shot` with the container's own `output` is the one that is exactly 1280x720. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011ZeH65zd6pFTgBSu52W9PE
84 lines
3.4 KiB
Nix
84 lines
3.4 KiB
Nix
# The flake's `checks` output. One file per check; this is only the wiring.
|
|
#
|
|
# unit -- pytest over tests/, against the nix/package.nix build
|
|
# vm-mcp -- the MCP server over stdio, against a live broker
|
|
# vm-basic -- nixosTest with a fake capture backend: module + wire contract
|
|
# vm-hyprland -- nixosTest with the real compositor and grim
|
|
# vm-sessions -- nixosTest with the real compositor and the session broker
|
|
# vm-ipc -- the compositor's IPC sockets, and an event that arrives
|
|
# vm-containers -- one output and one workspace per session
|
|
# vm-pointer -- the lease, the driver, and a click the application saw
|
|
# vm-keyboard -- the uploaded keymap, keyboard focus, and a decoded symbol
|
|
# vm-keyboard-de -- the same check with sessions.keyboard.layout = "de"
|
|
# vm-stream-firewall -- the stream's port in the guest's own running firewall
|
|
#
|
|
# What the guests need lives in checks/lib: `test-tools.nix` for the fake
|
|
# capture and the contract asserter, `session-tools.nix` for the event
|
|
# subscriber and the two input targets, `session-machine.nix` for the guest the
|
|
# session checks share, and `session-prelude.nix` for their test-script
|
|
# helpers.
|
|
#
|
|
# `vm-keyboard` and `vm-keyboard-de` are one file twice over, and that is the
|
|
# point: `sessions.keyboard.layout` reaches the uploaded keymap only through
|
|
# the driver unit's argv, and a single-layout check cannot tell that path from
|
|
# a hardcoded `us`. See the header of vm-keyboard.nix.
|
|
#
|
|
# Run them ONE AT A TIME. Each boots a VM with a software-rendered compositor;
|
|
# two at once on a two-core machine make the timing-sensitive assertions flake,
|
|
# and a flaky green is worth less than a slow one.
|
|
{
|
|
pkgs,
|
|
self,
|
|
system,
|
|
}:
|
|
let
|
|
hhstream = self.packages.${system}.hhstream;
|
|
hhstream-mcp = self.packages.${system}.hhstream-mcp;
|
|
hhsModule = self.nixosModules.default;
|
|
testTools = pkgs.callPackage ./lib/test-tools.nix { };
|
|
# The session checks take the same arguments; naming them once keeps a new
|
|
# check from being wired up with a different compositor or a different
|
|
# package than its neighbours.
|
|
sessionArgs = {
|
|
inherit hhstream hhsModule testTools;
|
|
};
|
|
in
|
|
{
|
|
unit = pkgs.callPackage ./unit.nix { inherit hhstream hhstream-mcp; };
|
|
|
|
vm-basic = pkgs.callPackage ./vm-basic.nix {
|
|
inherit hhstream hhsModule testTools;
|
|
};
|
|
|
|
vm-hyprland = pkgs.callPackage ./vm-hyprland.nix {
|
|
inherit hhstream hhsModule testTools;
|
|
};
|
|
|
|
vm-sessions = pkgs.callPackage ./vm-sessions.nix {
|
|
inherit hhstream hhsModule testTools;
|
|
};
|
|
|
|
vm-ipc = pkgs.callPackage ./vm-ipc.nix sessionArgs;
|
|
|
|
vm-containers = pkgs.callPackage ./vm-containers.nix sessionArgs;
|
|
|
|
vm-pointer = pkgs.callPackage ./vm-pointer.nix sessionArgs;
|
|
|
|
vm-keyboard = pkgs.callPackage ./vm-keyboard.nix sessionArgs;
|
|
|
|
vm-keyboard-de = pkgs.callPackage ./vm-keyboard.nix (
|
|
sessionArgs // { keyboardLayout = "de"; }
|
|
);
|
|
|
|
# Not a `sessionArgs` consumer: this one is about the module's own options,
|
|
# not about the broker or the compositor (see the file's header).
|
|
vm-stream-firewall = pkgs.callPackage ./vm-stream-firewall.nix {
|
|
inherit hhstream hhsModule testTools;
|
|
};
|
|
|
|
# The session machine again, plus `mcp.enable`, driven over stdio by a
|
|
# JSON-RPC client the check writes itself. `sessionArgs` plus the one package
|
|
# the others have no reason to carry.
|
|
vm-mcp = pkgs.callPackage ./vm-mcp.nix (sessionArgs // { inherit hhstream-mcp; });
|
|
}
|