From 21e09998114a866ae76ecef68d660e84561daa44 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 4 Nov 2026 11:03:55 -0300 Subject: test: the process runner, test/process.zig (docs/next-tests.md, the user's one runner): Files, a running pardes's file tree over its socket with Session's method names (read, write, expect, keys, click, where, screen, focused, newPane, at), dialled by pid or path, and Detached, a `pardes --detach` in a throwaway root that is its HOME, runtime and config directory, with no daemon (PARDES_DAEMON=off) so nothing outlives it, its stderr kept and said if it exits early; the pty mode is e2e_harness's Harness with process.of; the process-test step runs test/process_test.zig over test/process/*.zig, its first case fs.py's keys_and_mouse (gone from fs.py); snap9p reads /screen through Files; all 113 snap scripts pass Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/process/other_files.zig | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/process/other_files.zig (limited to 'test/process') diff --git a/test/process/other_files.zig b/test/process/other_files.zig new file mode 100644 index 00000000..178b20cd --- /dev/null +++ b/test/process/other_files.zig @@ -0,0 +1,36 @@ +//! docs/typ/reference.typ, Other files , through a real +//! session's socket. +const std = @import("std"); +const process = @import("../process.zig"); + +pub const cases = .{ + .{ "other-files: kbdin and mousein drive a detached session as the user would, each write done before it is answered", keysAndMouse }, +}; + +/// A script types and clicks as the user does: no sleep or poll between a +/// write and the read that checks it; where to click is read off /screen. +/// (test/fs.py's keys_and_mouse, the first case written through the files +/// alone.) +fn keysAndMouse(gpa: std.mem.Allocator, exe: [:0]const u8) !void { + var d = try process.Detached.start(gpa, exe, "kbd"); + defer d.deinit(); + const f = &d.files; + var buf: [4096]u8 = undefined; + try @import("../e2e_harness.zig").writeFile(try std.fmt.bufPrintSentinel(&buf, "{s}/target.txt", .{d.root()}, 0), "hello-target\n"); + const serial = try f.newPane(); + try f.write(f.at("/pane/{d}/body", .{serial}), "see \n"); + try f.write("/focus", f.at("{d}\n", .{serial})); + try f.keys("Atarget.txt\x1b"); + try f.expect(f.at("/pane/{d}/body", .{serial}), "see target.txt\n"); + try f.click("target.txt", 2, 4); + var index = std.mem.splitBackwardsScalar(u8, std.mem.trimEnd(u8, try f.read("/index"), "\n"), '\n'); + const last = index.first(); + try std.testing.expect(std.mem.endsWith(u8, last, "target.txt 1")); + const opened = try std.fmt.parseInt(u32, last[0..std.mem.indexOfScalar(u8, last, ' ').?], 10); + try std.testing.expect(opened != serial); + try f.expect(f.at("/pane/{d}/body", .{opened}), "hello-target\n"); + // Undone from the keyboard, as the user would: u in normal mode. + try f.write("/focus", f.at("{d}\n", .{serial})); + try f.keys("u"); + try f.expect(f.at("/pane/{d}/body", .{serial}), "see \n"); +} -- cgit v1.3