summaryrefslogtreecommitdiff
path: root/test/replicas.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/replicas.zig')
-rw-r--r--test/replicas.zig22
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) {