summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/replica.zig51
1 files changed, 51 insertions, 0 deletions
diff --git a/core/replica.zig b/core/replica.zig
index 10eba502..49ae4594 100644
--- a/core/replica.zig
+++ b/core/replica.zig
@@ -6436,6 +6436,57 @@ test "a closed terminal with a kitty image brought back on a client: its image d
try agrees(a, r);
}
+/// The core's fields whose digests differ between the session and a
+/// client, named (tape.partsDiffer); empty when they agree.
+fn partsApart(a: *Authority, r: *Replica, arena: std.mem.Allocator) ![]const u8 {
+ const want = try arena.create(tape.Parts);
+ const got = try arena.create(tape.Parts);
+ const w = digested: {
+ const was = Stepping.begin(&a.t, null);
+ defer was.end();
+ break :digested tape.digestParts(a.core, want);
+ };
+ const g = digested: {
+ const was = Stepping.begin(&r.t, &r.epoch);
+ defer was.end();
+ break :digested tape.digestParts(r.core(), got);
+ };
+ return if (std.mem.eql(u64, w, g)) "" else tape.partsDiffer(g, w, arena);
+}
+
+test "a terminal's program shows a kitty image under screen state: the client's emulator never has it, and its tag says what the session's does" {
+ if (pardes.Term.ops == null) return error.SkipZigTest; // a shell
+ const gpa = std.testing.allocator;
+ var arena: std.heap.ArenaAllocator = .init(gpa);
+ defer arena.deinit();
+ const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .boot = .tty }, TestHost.host(), true);
+ defer a.deinit();
+ var screens: Screens = .init(gpa);
+ defer screens.deinit(a.core);
+ const peer = try screens.addPeer();
+ const r = try Replica.init(gpa, 1, try a.unit(0, 0), true);
+ defer r.deinit();
+ const shell: u8 = for (a.core.panes, 0..) |slot, id| {
+ if (slot) |pane| if (pane.isTerminal()) break @intCast(id);
+ } else return error.NoShell;
+ try deliver(a, &screens, peer, r, .flush);
+ try std.testing.expectEqualStrings("", try partsApart(a, r, arena.allocator()));
+ // In the session's order: the pump's unit, then what its terminals came
+ // to; then a step after both, on every side.
+ a.output(.{ .output = .{ .pane = .at(shell), .bytes = "\x1b_Ga=T,i=7,f=24,s=2,v=2;ESIzESIzESIzESIz\x1b\\" } });
+ r.confirm((try a.pending()).?);
+ r.settle();
+ try deliver(a, &screens, peer, r, .flush);
+ r.confirm(try a.local(.{ .focus = true }));
+ r.settle();
+ try std.testing.expect(pardes.Term.hasImages(a.core.panes[shell].?.terminal));
+ try std.testing.expect(!pardes.Term.hasImages(r.core().panes[shell].?.terminal));
+ try std.testing.expectEqualStrings("", try partsApart(a, r, arena.allocator()));
+ try agrees(a, r);
+ const prefix = try pardes.tagline.prefixIn(r.core(), arena.allocator(), r.core().panes[shell].?);
+ try std.testing.expect(std.mem.indexOf(u8, prefix, " petscii:") != null);
+}
+
test "a far client's own Del of a pane whose kind's state is not plain, rolled back by another's unit: the pane comes back whole, and is closed again with the session's order" {
const gpa = std.testing.allocator;
const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .file = "mise.toml" }, TestHost.host(), false);