diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-03 16:59:08 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-03 17:13:25 -0300 |
| commit | 023793be1112bc35b50551580d273f4cf611b3da (patch) | |
| tree | 4167a4e0435d545dbdb8e09e4f6578491b1dd1e2 /test/behaviour/log.zig | |
| parent | d1273bbd99daf9b1855d82bf315db8ede20abde5 (diff) | |
| download | pardes-023793be1112bc35b50551580d273f4cf611b3da.tar.gz pardes-023793be1112bc35b50551580d273f4cf611b3da.zip | |
test: sixteen of src/ninep/ctl.zig's tests through the 9P tree alone, in new test/behaviour/{log,mounts,rules,settings}.zig and appended to edit, columns_and_tags, look_and_exec, panes and root_ctl: the log's msg and err records (a root ctl's message the session's, the same failure counted, a root exec's err its pane's), Mount's refusals (and nothing mounted, read from Unmount), Pager and Shell read back from the root ctl, a control character in any ctl and in any tag, a bad command inside an Edit block, a look's :addr and file:addr, the root look's file:/re/ from the dot, exec's readback, focus (a column tag's keyboard taken by Newcol), the pane ctl's and the root ctl's words; each checked to fail against a break: the (xN) count one short, msg - written as msg 0, a root exec's err left as -, a missing socket's words changed, Pager defaulting off, a bare Shell not clearing, tree.zig's ctl check skipped, DEL taken in a tag, an Edit block's bad command naming }, a look's address evaluated from 0 not the dot, no results recorded, focus leaving the header the keyboard, "not a pane control message", every setting value taken
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/behaviour/log.zig')
| -rw-r--r-- | test/behaviour/log.zig | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/behaviour/log.zig b/test/behaviour/log.zig new file mode 100644 index 00000000..21bccdf0 --- /dev/null +++ b/test/behaviour/log.zig @@ -0,0 +1,36 @@ +//! docs/typ/reference.typ, The log <log>. +const std = @import("std"); +const Session = @import("session").Session; + +fn has(hay: []const u8, needle: []const u8) bool { + return std.mem.indexOf(u8, hay, needle) != null; +} + +test "log: a message from a root ctl write is the session's, and its own words stand for its Verbose announcement" { + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + try s.write("/ctl", "Kill\n"); + const log = try s.read("/log"); + try std.testing.expect(has(log, "\nmsg - Kill: nothing running\n")); + try std.testing.expectEqual(@as(usize, 1), std.mem.count(u8, log, "Kill")); +} + +test "log: a builtin that fails a ctl write logs only its err, so the same failure again is counted" { + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + // Another failure first: the pane's `new` is logged after it. + _ = try s.refused("/ctl", "Unmount yyy\n"); + for (0..3) |_| try std.testing.expect(try s.refused("/ctl", "Unmount zzz\n") != 0); + const log = try s.read("/log"); + try std.testing.expect(std.mem.endsWith(u8, log, "err - ctl: Unmount: no such mount zzz (x3)\n")); + try std.testing.expect(!has(log, "msg - Unmount")); +} + +test "log: a root exec that fails logs its err against the pane it ran at" { + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + const n = try s.focused(); + try s.write(s.at("/pane/{d}/body", .{n}), "unsaved\n"); + try std.testing.expect(try s.refused("/exec", "Exit\n") != 0); + try std.testing.expect(has(try s.read("/log"), s.at("err {d} exec: ", .{n}))); +} |
