summaryrefslogtreecommitdiff
path: root/src/replica.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/replica.zig')
-rw-r--r--src/replica.zig49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/replica.zig b/src/replica.zig
index 3af1caac..2cbf0c0c 100644
--- a/src/replica.zig
+++ b/src/replica.zig
@@ -239,6 +239,18 @@ pub const Authority = struct {
a.batched += 1;
}
+ /// A pass of its host's loop with no input (a frame's wake): its pump
+ /// alone, its clock advanced and what is due ticked, into the open
+ /// batch.
+ pub fn pump(a: *Authority) void {
+ a.t.no_digest = true;
+ defer a.t.no_digest = false;
+ const was = Stepping.begin(&a.t, null);
+ a.core.pump(a.host) catch {};
+ was.end();
+ a.batched += 1;
+ }
+
/// The open batch as a unit, or null: what the host sends before it
/// steps any other input, and once a frame.
pub fn pending(a: *Authority) !?[]const u8 {
@@ -4173,6 +4185,43 @@ test "a replica joined from the session's dump replays the units after it" {
try std.testing.expectEqual(digestOf(a), r.digest());
}
+test "a replica joined from a dump replays a step that opens a file's pane and says it has no room for it: its /log, empty, is not the session's" {
+ const gpa = std.testing.allocator;
+ // No rows for a second pane: the Look's pane of a kind is made, the
+ // placement says it has no room (a message in the step that made the
+ // pane, which was not in /log yet), and the pane goes.
+ const a = try Authority.init(gpa, .{ .cols = 80, .rows = 5, .file = "mise.toml" }, TestHost.host(), false);
+ defer a.deinit();
+ var words: [64]pardes.Kind.LoadedWord = undefined;
+ const zon = pardes.Kind.loadedOf(&Zon.ops, "/x/zon.so", @splat(9), &words);
+ _ = try a.local(.{ .addon = .{ .op = .load, .pane = 0, .kind = &zon } });
+ const r = try joinedNow(a, 1, 0);
+ defer r.deinit();
+ try std.testing.expectEqual(digestOf(a), r.digest());
+ var whole: [libc.PATH_MAX]u8 = undefined;
+ var look: [libc.PATH_MAX + 8]u8 = undefined;
+ const path = std.mem.span(libc.realpath("build.zig.zon", &whole) orelse return error.SkipZigTest);
+ r.confirm(try a.local(.{ .command = try std.fmt.bufPrint(&look, "Look {s}", .{path}) }));
+ if (r.diverged) |why| std.debug.print("diverged: {s}\n", .{why});
+ try std.testing.expect(r.diverged == null);
+ try std.testing.expectEqual(digestOf(a), r.digest());
+}
+
+/// A kind of `.zon` files, for a replica's Look of one (a picture's,
+/// as a kind's pane is made).
+const Zon = struct {
+ const pa = pardes.Kind.c;
+ fn open(_: [*c]const u8, _: [*c]const u8, _: u64) callconv(.c) ?*anyopaque {
+ return pardes.Kind.api.alloc.?(4);
+ }
+ fn paint(_: ?*anyopaque, _: [*c]const pa.pa_window, _: [*c]pa.pa_paint) callconv(.c) void {}
+ const ops = std.mem.zeroInit(pardes.Kind.Ops, .{
+ .head = std.mem.zeroInit(pa.pa_head, .{ .size = @sizeOf(pa.pa_head), .abi = pardes.Kind.abi, .name = "zon".* ++ @as([13]u8, @splat(0)), .version = 1, .exts = ".zon" }),
+ .open = open,
+ .paint = paint,
+ });
+};
+
test "a replica joined from a themed dump paints its taglines in the restored theme" {
const gpa = std.testing.allocator;
const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "build.zig" }, TestHost.host(), false);