diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 16:46:18 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-04 16:55:32 -0300 |
| commit | 6bcb18e021a09d51539e628106a594748637ead2 (patch) | |
| tree | 954996560c694dd7f0ab410aa01def00d25c33fe /test/behaviour | |
| parent | be3985092df1c3388cfa09ca5e989d2fa66f55ec (diff) | |
| download | pardes-6bcb18e021a09d51539e628106a594748637ead2.tar.gz pardes-6bcb18e021a09d51539e628106a594748637ead2.zip | |
test: fs.py's inline checks, quic_test, workflow_canary, python_repl_runs_one_line and signal_cleans_up moved to Zig, deleted from fs.py (its named cases stay): 21 process cases in test/process/ (flags: bad options refused in words, --9p naming the socket, forwarding a launch inside a session and the launches that start their own (mount, name, tcp, load, shells, toggle, quic), --wait and its refusals, pardes - and its +Pager (escapes, inks and Filter, progress, 11 MiB, the 256 MiB cut), $winid, the stdin boot, no terminal to draw on, a killed tty editor and its swept sockets, a signal unlinking the socket; mounts: --mount at startup, Mount and Unmount at run time, QUIC and TCP v4 and v6 detached and in a pty (skipped without -Dquic=true, passed with it); tree: the root and /os, 256-byte frames, a held ctl line, a frozen /screen, Look's precedence, 255-byte names; root-ctl: Restore detached and in a pty; builtins: Lspinfo; look-and-exec: the canary; repls: Python's pyrepl) and 3 behaviour tests (a 60 KB body write, truncated, a missing pane refused; a body write's EI record; keyword colour, not bold); process.zig gains, under fsb:, Conn.dialSized, dialTcp, replace, newPane, serials, look, pane, exec, execRefused, removePane, Files.fg, Detached.exists, abs, startTty, and Child (a program in a root's environment, its stdin fed, on a pty if asked, its stderr kept), run, code, entries, canonical, quicIncluded, nowMs, nap, has, check; each checked to fail against a break (no such option reworded, SyntaxBold on by default, a body insert's record not EI, Grep's miss reworded, already inside pardes reworded, a session already running reworded, Lspinfo's servers line reworded, no terminal to draw on reworded, unknown control message reworded); behaviour, process, fs-unit and core tests and the rest of fs.py pass
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/behaviour')
| -rw-r--r-- | test/behaviour/event.zig | 11 | ||||
| -rw-r--r-- | test/behaviour/settings.zig | 34 | ||||
| -rw-r--r-- | test/behaviour/tree.zig | 15 |
3 files changed, 60 insertions, 0 deletions
diff --git a/test/behaviour/event.zig b/test/behaviour/event.zig index 77a80e30..65222175 100644 --- a/test/behaviour/event.zig +++ b/test/behaviour/event.zig @@ -69,3 +69,14 @@ test "event: a bad event record says what is wrong with it" { try std.testing.expect(has(s.said, c[1])); } } + +test "event: a write to the body is an EI record to the reader holding event" { + var s = try Session.initFile(std.testing.allocator, "replaced\n"); + defer s.deinit(); + const n = try s.focused(); + const event = try s.hold(s.at("/pane/{d}/event", .{n}), 0); + defer s.clunk(event); + try s.write(s.at("/pane/{d}/body", .{n}), "event\n"); + const record = try s.readFid(event); + try std.testing.expect(std.mem.startsWith(u8, record, "EI") and has(record, "event\n")); +} diff --git a/test/behaviour/settings.zig b/test/behaviour/settings.zig index a24a3010..9a14ff50 100644 --- a/test/behaviour/settings.zig +++ b/test/behaviour/settings.zig @@ -269,3 +269,37 @@ test "settings: every on/off setting the root ctl reads flips when its word is w try std.testing.expectEqualStrings("Theme acme", try setting(&s, "Theme")); try std.testing.expectEqualStrings("Shell /bin/sh", try setting(&s, "Shell")); } + +/// A cell's style (one of `Session.styles`) as its bold flag and ink. +fn look(s: *Session, style: []const u8) !struct { bool, []const u8 } { + const a = s.arena.allocator(); + const json = try std.json.parseFromSliceLeaky(std.json.Value, a, style, .{}); + return .{ json.object.get("bold").?.bool, try std.json.Stringify.valueAlloc(a, json.object.get("fg").?, .{}) }; +} + +test "settings: a keyword is coloured apart from the text beside it, and not bold (SyntaxBold is off by default), at a long file's end" { + var s = try Session.initFile(std.testing.allocator, "initial\n"); + defer s.deinit(); + const n = try s.focused(); + try s.write(s.at("/pane/{d}/name", .{n}), "keywords.zig\n"); + var source: std.ArrayList(u8) = .empty; + for (0..9999) |_| try source.appendSlice(s.arena.allocator(), "// padding\n"); + try source.appendSlice(s.arena.allocator(), "fn check() void {\n if (true) return;\n}\n"); + try s.replace(s.at("/pane/{d}/body", .{n}), source.items); + const screen = try s.screen(); + const styles = try s.styles(); + const cols = std.mem.indexOfScalar(u8, screen, '\n').?; + try std.testing.expectEqual(styles.len, cols * (std.mem.count(u8, screen, "\n") + 1)); + for ([_][]const u8{ "fn", "if" }) |word| { + const col, const row = try s.where(s.at("{s} ", .{word})); + const at = row * cols + col; + _, const ink = try look(&s, styles[at]); + for (styles[at..][0..word.len]) |cell| { + const bold, const each = try look(&s, cell); + try std.testing.expect(!bold); + try std.testing.expectEqualStrings(ink, each); + } + _, const plain = try look(&s, styles[at + word.len]); + try std.testing.expect(!std.mem.eql(u8, ink, plain)); + } +} diff --git a/test/behaviour/tree.zig b/test/behaviour/tree.zig index 7f9b37a4..56806589 100644 --- a/test/behaviour/tree.zig +++ b/test/behaviour/tree.zig @@ -42,3 +42,18 @@ test "tree: a terminal is listed as term with its directory as name, which a wri try std.testing.expectEqual(@as(u16, 22), try s.refused(s.at("/pane/{d}/name", .{n}), "/elsewhere\n")); try std.testing.expect(std.mem.startsWith(u8, s.said, "invalid rename: a terminal is named")); } + +test "tree: a body takes a 60 KB write whole, a truncating one replaces it, and a pane not there is refused" { + var s = try Session.initFile(std.testing.allocator, "initial\n"); + defer s.deinit(); + var payload: std.ArrayList(u8) = .empty; + for (0..3000) |_| try payload.appendSlice(s.arena.allocator(), "const value = \"λ\";\n"); + const n = try s.newPane(); + const body = s.at("/pane/{d}/body", .{n}); + try s.write(body, payload.items); + try s.expect(body, payload.items); + try s.replace(body, "replaced\n"); + try s.expect(body, "replaced\n"); + try std.testing.expectError(error.Refused, s.read("/pane/4294967295/body")); + try s.expect(body, "replaced\n"); +} |
