From d197289c331365081295cb44f27ee2893294cffa Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 3 Nov 2026 16:17:51 -0300 Subject: test: the behaviour-test step and test/session.zig, T1 of docs/next-tests.md: a Session drives the core as a 9P client does (walk by path, open, read or write, clunk, held lines run at the clunk as src/9p_io.zig runs them), the core opaque and the step's module importing session alone, so a behavioural test cannot reach past the 9P tree; keys (kbdin), click (on text found on /screen, mousein), screen, focused, refused and the refusal's words; test/behaviour/{other_files,panes,edit}.zig, a file a section of the reference: kbdin and mousein, a collapsed pane's ctl, name's leading blank, Putall, Edit blocks, moved out of src/ninep/ctl.zig (an Edit block left open now checked as a client sees it, an err in the log at its clunk), each checked to fail against a break (collapsed left off the ctl read, Putall saving nothing); the plan doc says the layout, the decisions and the progress Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- build.zig | 27 +++++++ docs/next-tests.md | 40 ++++++++- src/ninep/ctl.zig | 85 ------------------- test/behaviour.zig | 9 +++ test/behaviour/edit.zig | 21 +++++ test/behaviour/other_files.zig | 23 ++++++ test/behaviour/panes.zig | 40 +++++++++ test/session.zig | 179 +++++++++++++++++++++++++++++++++++++++++ 8 files changed, 335 insertions(+), 89 deletions(-) create mode 100644 test/behaviour.zig create mode 100644 test/behaviour/edit.zig create mode 100644 test/behaviour/other_files.zig create mode 100644 test/behaviour/panes.zig create mode 100644 test/session.zig diff --git a/build.zig b/build.zig index 4485140d..8a9451eb 100644 --- a/build.zig +++ b/build.zig @@ -1864,6 +1864,33 @@ pub fn build(b: *std.Build) void { pane_test_step.dependOn(&run_pane_tests.step); if (testMatch(b, unit_profile, test_filters, pane_test_step)) |check| check.addArtifactArg(pane_tests); + // The behavioural tests (docs/next-tests.md): their module has the + // session alone, so none can reach past what a 9P client sees. + const session_module = b.createModule(.{ + .target = target, + .optimize = optimize, + .root_source_file = b.path("test/session.zig"), + .link_libc = true, + }); + session_module.addImport("pardes", core_module); + const behaviour_module = b.createModule(.{ + .target = target, + .optimize = optimize, + .root_source_file = b.path("test/behaviour.zig"), + .link_libc = true, + }); + behaviour_module.addImport("session", session_module); + const behaviour_tests = b.addTest(.{ .root_module = behaviour_module, .filters = test_filters }); + if (test_nonce) |nonce| behaviour_tests.root_module.addImport("test_rebuild_nonce", nonce); + test_build.dependOn(&behaviour_tests.step); + const run_behaviour_tests = b.addRunArtifact(behaviour_tests); + run_behaviour_tests.has_side_effects = true; + unit_step.dependOn(&run_behaviour_tests.step); + if (unit_match) |check| check.addArtifactArg(behaviour_tests); + const behaviour_test_step = b.step("behaviour-test", "run the behavioural tests, through the 9P tree alone (test/behaviour/)"); + behaviour_test_step.dependOn(&run_behaviour_tests.step); + if (testMatch(b, unit_profile, test_filters, behaviour_test_step)) |check| check.addArtifactArg(behaviour_tests); + // Kitty graphics conformance at the core: what a terminal pane's // program sends, what it reads back, what ghostty stores and what a // frame draws (test/kitty.zig). The end-to-end arm, through a real diff --git a/docs/next-tests.md b/docs/next-tests.md index f05a6e73..7dbbff60 100644 --- a/docs/next-tests.md +++ b/docs/next-tests.md @@ -15,9 +15,29 @@ agent's survey. The `e2e` line (kbdin, mousein) is its first step. - **T1, in-process 9P, is the main tier.** The core is driven only through `serveFs` (src/ninep/testing.zig's `call`, `rd`, `wr`): as behavioural as a client on a socket, and milliseconds a case. -- **Process-level tests (T2) get a Zig runner, not Python.** The Python - suites (test/fs.py and the rest) stay as examples of scripting a session - and are not grown. +- **Process-level tests (T2) get a Zig runner, not Python:** test/snapshot.zig, + the `.snap` runner, which already forks the app in a pty and has a 9P + client (`snap9p`), grows 9P verbs (`9pwrite`, `9pexpect`, `signal`). The + Python suites (test/fs.py and the rest) stay as examples of scripting a + session and are not grown. +- **Layout (from a ponytail review, 2026-11-03):** + - **test/session.zig is the T1 `Session`:** a 9P client's walk, open, + read or write, clunk, by path, with the core opaque. + - **test/behaviour/