summaryrefslogtreecommitdiff
path: root/src/replica.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/replica.zig')
-rw-r--r--src/replica.zig25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/replica.zig b/src/replica.zig
index 439f71a2..da0c3e64 100644
--- a/src/replica.zig
+++ b/src/replica.zig
@@ -3266,6 +3266,31 @@ test "a delta applied under a speculation outlives its rollback: the terminal st
for (rows_a[rows_a.len - shown ..], rows_r[rows_r.len - shown ..]) |x, y| try std.testing.expectEqualStrings(x, y);
}
+test "a closed terminal brought back on a screen-state replica: its emulator on the C heap, never the rollback epoch's" {
+ if (comptime !terminal.enabled) return error.SkipZigTest;
+ const gpa = std.testing.allocator;
+ const a = try Authority.init(gpa, .{ .cols = 80, .rows = 24, .boot = .tty }, TestHost.host(), true);
+ defer a.deinit();
+ 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;
+ a.core.active = shell;
+ r.confirm(try a.local(.{ .command = "Del" }));
+ try std.testing.expectEqual(@as(usize, 1), a.core.store.closed.items.len);
+ var line: [32]u8 = undefined;
+ r.confirm(try a.local(.{ .command = try std.fmt.bufPrint(&line, "Look @p{d}", .{a.core.store.closed.items[0].serial}) }));
+ try std.testing.expect(r.diverged == null);
+ const back = for (r.core().panes) |slot| {
+ if (slot) |pane| if (pane.terminal) |state| break state;
+ } else return error.NotBack;
+ // Its deltas write it while a copy is held, and its screen replica's
+ // blobs are freed with the C heap's (`deinit`): the epoch's, a rollback
+ // freed what they held and the exit freed them behind its back (H21).
+ try std.testing.expect(r.epoch.owns(@intFromPtr(back)) == null);
+}
+
test "a view that sized a terminal closing leaves nothing queued: the others' replicas copy, type and agree" {
if (comptime !terminal.enabled) return error.SkipZigTest;
const gpa = std.testing.allocator;