diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-04 16:33:08 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-04 16:48:55 -0300 |
| commit | ef0d017705146a74bf7cc2706b9796f227ea6977 (patch) | |
| tree | b4f14a8724055be7918416b8893c32760d0ee7f8 /test/behaviour | |
| parent | be3985092df1c3388cfa09ca5e989d2fa66f55ec (diff) | |
| download | pardes-ef0d017705146a74bf7cc2706b9796f227ea6977.tar.gz pardes-ef0d017705146a74bf7cc2706b9796f227ea6977.zip | |
test: test/fs.py's discovery, run_file, exit_answers, unattended_messages_expire, directory_panes, putall_answers_after_its_saves, new_terminals_named_once, recent_survives_restart, store_shared_between_windows, odd_paths, delcol_last_keeps_window, cut_writes and edit_commands in Zig, the Python deleted (and its now unused newest, walk_tree, del_twice and the --discovery switch): at T2 in new test/process/{tree,terminals,root_ctl,edit}.zig and other_files.zig (the tree's listing, stats, log follow, ctl lock, focus, commands, sel, Save making directories, the 16 slots; a write cut at an 8 KiB msize; pty/run's answers, busy and shell gone; terminals named once; Exit; MessageLinger unattended; Putall; odd paths and ThemeFile; Edit's < | > off the loop, a held write answered after a later read and flushed, X and w; /recent across a restart and a store two sessions share), at T1 a directory pane in test/behaviour/look_and_exec.zig and 9P's new after Delcol of the last column in columns_and_tags.zig; discovery brought up to the tree as documented (sessions, kbdin, mousein at the root, /index stats 0, a sel write stays selected, the unknown-message words, a look's line in dot, a Save under / refused as permission denied), as the Python had gone stale; process.Conn gains replace, writeCut, create, newPane, newest, look, dialRefusal, send and answer, and process.sleep; a failing process test prints its error return trace; each checked to fail against a break (a detached session 161 wide, 17 connection slots, a pty taking one row, Edit's failure said as exit code, ThemeFile's .zon words changed, Exit not quitting, unattended messages never expiring, a directory pane's sub/ without its slash, Putall's modified-on-disk words changed, /recent saying shut for closed, a missing interpreter said as missing)
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/columns_and_tags.zig | 3 | ||||
| -rw-r--r-- | test/behaviour/look_and_exec.zig | 42 |
2 files changed, 45 insertions, 0 deletions
diff --git a/test/behaviour/columns_and_tags.zig b/test/behaviour/columns_and_tags.zig index b9e3b3f5..22f55774 100644 --- a/test/behaviour/columns_and_tags.zig +++ b/test/behaviour/columns_and_tags.zig @@ -133,6 +133,9 @@ test "columns-and-tags: Delcol on the last column leaves the window, drawn and t try s.write("/ctl", "Newcol\n"); try s.write(s.at("/col/{d}/ctl", .{try s.column(0)}), "New\n"); try expectEqualStrings(s.at("{d}:{d}", .{ try s.column(0), try s.focused() }), try s.columns()); + // And 9P's new makes a pane there. + const made = try s.newPane(); + try std.testing.expect(std.mem.indexOf(u8, try s.read("/index"), s.at("\n{d} ", .{made})) != null); } test "columns-and-tags: New is a column tag's word, in no pane's tag nor the workspace's" { diff --git a/test/behaviour/look_and_exec.zig b/test/behaviour/look_and_exec.zig index 0d8056da..c46ca394 100644 --- a/test/behaviour/look_and_exec.zig +++ b/test/behaviour/look_and_exec.zig @@ -713,3 +713,45 @@ test "look-and-exec: a pane's tagexec runs a word as a click in its tag, and rea try std.testing.expect(std.mem.indexOf(u8, try s.read("/log"), "from the tag") != null); try s.expect(tagexec, s.at("{d}\n", .{n})); } + +test "look-and-exec: a look at a directory opens a pane listing it, as acme's directory window: named with a trailing /, its entries, ctl's isdir 1, get reading it again" { + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.createDirPath(std.testing.io, "listed/sub"); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "listed/.dot", .data = "" }); + var s = try Session.initFile(std.testing.allocator, "x\n"); + defer s.deinit(); + const dir = s.at("{s}/listed", .{try tmpPath(&s, &tmp)}); + const scratch = try s.newPane(); + try s.write(s.at("/pane/{d}/look", .{scratch}), s.at("{s}\n", .{dir})); + const serial = try std.fmt.parseInt(u32, std.mem.trim(u8, try s.read("/look"), "\n"), 10); + try std.testing.expect(serial != scratch); + const words = struct { + fn of(text: []const u8, buf: [][]const u8) []const []const u8 { + var it = std.mem.tokenizeAny(u8, text, " \n"); + var n: usize = 0; + while (it.next()) |w| : (n += 1) buf[n] = w; + return buf[0..n]; + } + }.of; + var buf: [16][]const u8 = undefined; + var rows = std.mem.tokenizeScalar(u8, try s.read("/index"), '\n'); + const row = while (rows.next()) |r| { + if (std.mem.startsWith(u8, r, s.at("{d} ", .{serial}))) break words(r, &buf); + } else return error.NoRow; + try std.testing.expectEqualStrings("text", row[1]); + try std.testing.expectEqualStrings("0", row[2]); + try std.testing.expectEqualStrings(s.at("{s}/", .{dir}), row[3]); + const body = words(try s.read(s.at("/pane/{d}/body", .{serial})), &buf); + try std.testing.expectEqual(@as(usize, 2), body.len); + try std.testing.expectEqualStrings(".dot", body[0]); + try std.testing.expectEqualStrings("sub/", body[1]); + try std.testing.expectEqualStrings("1", words(try s.read(s.at("/pane/{d}/ctl", .{serial})), &buf)[3]); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "listed/later", .data = "" }); + try s.write(s.at("/pane/{d}/ctl", .{serial}), "get\n"); + const again = words(try s.read(s.at("/pane/{d}/body", .{serial})), &buf); + try std.testing.expectEqual(@as(usize, 3), again.len); + try std.testing.expectEqualStrings(".dot", again[0]); + try std.testing.expectEqualStrings("later", again[1]); + try std.testing.expectEqualStrings("sub/", again[2]); +} |
