diff options
| author | Gabriel Schneider <[email protected]> | 2026-10-30 15:38:44 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-30 16:49:16 -0300 |
| commit | c890a00a52af0e6318bc2cbef755312b9e8602d4 (patch) | |
| tree | 1275e1dde7b9201fd9d8b7deb032930b47511b3b /test | |
| parent | ac57e8c3a05cdd8f587b6faf47e7f9d2c4357dee (diff) | |
| download | pardes-c890a00a52af0e6318bc2cbef755312b9e8602d4.tar.gz pardes-c890a00a52af0e6318bc2cbef755312b9e8602d4.zip | |
test/replicas.zig: the clients look at files and close panes, open the Panes and Recent pickers and jump, now and then: the store's and Recent's rows, a closed pane's jumps, from replicas that rolled back over them
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'test')
| -rw-r--r-- | test/replicas.zig | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/test/replicas.zig b/test/replicas.zig index baaa669d..b1ceffab 100644 --- a/test/replicas.zig +++ b/test/replicas.zig @@ -147,8 +147,10 @@ const Totals = struct { }; /// One client's next input: monkey.zig's mix, as events, and now and then -/// a wheel over the shell pane, which scrolls its history into view. -fn nextEvent(random: std.Random, buf: *[64]u8, wheel_at: ?[2]u16) pardes.Event { +/// a wheel over the shell pane, which scrolls its history into view; a +/// file looked at (`looks`, its words) and a pane closed, the Panes and +/// Recent pickers (the store's and Recent's rows, the authority's), a jump. +fn nextEvent(random: std.Random, buf: *[64]u8, wheel_at: ?[2]u16, looks: []const []const u8) pardes.Event { const typed = "abcdefghijklmnopqrstuvwxyz0123456789 -_=+,:;()"; const normal = "hjklwbe0$xpuyoOiaAIdcv.nN%sC"; switch (random.uintLessThan(u8, 43)) { @@ -174,11 +176,16 @@ fn nextEvent(random: std.Random, buf: *[64]u8, wheel_at: ?[2]u16) pardes.Event { for (buf[0..n]) |*c| c.* = typed[random.uintLessThan(usize, typed.len)]; return .{ .paste = buf[0..n] }; }, - 36 => return .{ .command = switch (random.uintLessThan(u8, 4)) { + 36 => return .{ .command = switch (random.uintLessThan(u8, 10)) { 0 => "Newcol", 1 => "Zerox", 2 => "Undo", - else => "Redo", + 3 => "Redo", + 4 => "Search Panes", + 5 => "Search Recent", + 6, 7 => looks[random.uintLessThan(usize, looks.len)], + 8 => "Del", + else => return .{ .key = .{ .cp = if (random.boolean()) 'o' else 'i', .ctrl = true } }, } }, 37 => return .{ .resize = .{ .cols = @intCast(random.intRangeAtMost(u16, 60, 120)), .rows = @intCast(random.intRangeAtMost(u16, 16, 40)) } }, 38 => return .{ .mouse = .{ .button = .left, .kind = .press, .col = random.uintLessThan(u16, 80), .row = random.uintLessThan(u16, 24) } }, @@ -225,9 +232,12 @@ fn run(r: Run, dir: []const u8, totals: *Totals) !void { host.echo.deinit(gpa); } var paths: [3][256:0]u8 = undefined; - for (&paths, 0..) |*p, i| { + var look_lines: [3][300]u8 = undefined; + var looks: [3][]const u8 = undefined; + for (&paths, &look_lines, &looks, 0..) |*p, *l, *look, i| { const path = try std.fmt.bufPrintSentinel(p, "{s}/f{d}.zig", .{ dir, i }, 0); try writeFile(path, 60 + 40 * i); + look.* = try std.fmt.bufPrint(l, "Look {s}", .{path}); } // The tty's own boot (a raw shell, a text pane under it), then three // files looked at: keys go to the last, a pane's shell echoes. @@ -316,7 +326,7 @@ fn run(r: Run, dir: []const u8, totals: *Totals) !void { .input => { const c = m.who - 1; var buf: [64]u8 = undefined; - const ev = nextEvent(random, &buf, if (c == 0) wheel_at else null); + const ev = nextEvent(random, &buf, if (c == 0) wheel_at else null, &looks); const before = reps[c].stats; const msg = try gpa.dupe(u8, try reps[c].input(ev)); if (trace) std.debug.print("{d} ms client {d}: {t} {s} -> {s}\n", .{ m.at / 1000, m.who, ev, switch (ev) { |
