From 53c2a95eff9c67871d6004baa3e7d3c3b2a195fd Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Tue, 3 Nov 2026 17:00:43 -0300 Subject: test: three of test/pdf.zig's look tests through the 9P tree alone (test/behaviour/look_and_exec): `:N` on a PDF from its look, the root's and `@pN:N` (the page read from its tag's [P/N]), its misses in the log (no page 0, no search hit, no text to address, one past the last); a page past the last a miss, open or not, opening nothing (/index); a +PdfSections row's page checked against the outline; Session's lookFile and pdfPage; each checked to fail against a break (a PDF look turning to page 1 always, an open PDF's past-last page check dropped, Pdf.openPane taking .last for .refuse, the sections row's page check dropped) Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge --- test/session.zig | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'test/session.zig') diff --git a/test/session.zig b/test/session.zig index 8b3c5c41..f11a4c7f 100644 --- a/test/session.zig +++ b/test/session.zig @@ -182,6 +182,26 @@ pub const Session = struct { fn pardesOf(s: *Session) *Pardes { return @ptrCast(@alignCast(s.core)); } + + // pdf: + + /// A Look of `path` at the root (one relative to the working directory + /// made absolute first); the serial of the pane with the keyboard after. + pub fn lookFile(s: *Session, path: []const u8) !u32 { + var buf: [4096]u8 = undefined; + const abs = if (std.fs.path.isAbsolute(path)) path else s.at("{s}/{s}", .{ buf[0..try std.Io.Dir.cwd().realPath(std.testing.io, &buf)], path }); + try s.write("/look", s.at("{s}\n", .{abs})); + return s.focused(); + } + + /// The page a PDF pane shows and its pages, from its tag's `[page/pages]`. + pub fn pdfPage(s: *Session, n: u32) !struct { u32, u32 } { + const tag = try s.read(s.at("/pane/{d}/tag", .{n})); + const lo = std.mem.indexOf(u8, tag, " [") orelse return error.NoPage; + const close = std.mem.indexOfScalarPos(u8, tag, lo, ']') orelse return error.NoPage; + var it = std.mem.splitScalar(u8, tag[lo + 2 .. close], '/'); + return .{ try std.fmt.parseInt(u32, it.next().?, 10), try std.fmt.parseInt(u32, it.next() orelse return error.NoPage, 10) }; + } }; fn refusal(path: []const u8, r: Reply) error{Refused} { -- cgit v1.3