diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-21 17:47:24 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-21 18:02:13 -0300 |
| commit | aefdb402b577c270111e2736e175611def0833e7 (patch) | |
| tree | aafba458ecfa2e98b221c46b0e030ff67e0d9d57 /core | |
| parent | 3dc3e796a9b69ec35a8a920aa12f3e04e61a0ab5 (diff) | |
| download | pardes-aefdb402b577c270111e2736e175611def0833e7.tar.gz pardes-aefdb402b577c270111e2736e175611def0833e7.zip | |
tests: a plain client watching a kitty image in a terminal under screen state joins again for ever, caught twice: core/replica.zig "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" (an Authority and a Replica, the image fed in the session's order, a step after: the digests part in pane 0.tag, pane 0.tag_lead and pane 1.cwd, the last an inherited cwd that walks to the terminal's pane; `partsApart` names them) and test/daemon.py `kitty_image` (plain mode's list, alone `--kitty-image`: a detached session, a plain attach, the corpus scene 10's 8x8 RGB image printed in its shell, the client's joins counted over 5 s, 0 expected: on this base's Debug build 16 joins, 16 of 16 checks differ; on the installed build (6d937cd125ca) the same 16, 3.2 a second, session 20-30 ms and client 50-70 ms of CPU, 80 KB to the client's terminal); shell-test 1100/1104 with this test the one failure, core-test 898/1059 (161 skipped: it needs a shell)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core')
| -rw-r--r-- | core/replica.zig | 51 |
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); |
