diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-22 03:03:55 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-22 10:31:04 -0300 |
| commit | 9158de5d50831e115e14e2ed502300ee8c1d9930 (patch) | |
| tree | 2b5e60569307e02d82b19bd419279392a6da257b /test/terminal.zig | |
| parent | 70c9e3fbf9cdc7139b4da0142f3a44741a7e1491 (diff) | |
| download | pardes-9158de5d50831e115e14e2ed502300ee8c1d9930.tar.gz pardes-9158de5d50831e115e14e2ed502300ee8c1d9930.zip | |
term: screen_state.zig deleted, and the terminal module's side of the delta road (the old road's deletion, piece 5 of 8): core/term/screen_state.zig (1,213 lines: the encoder, tracks, peers' flights, a replica's apply and holes, its own soak and four tests) goes whole; core/term/terminal.zig loses `encode`/`encodeRows`/`encoder`/`encoderFree`/`track`/`untrack`/`replica`/`replicaFree`/`replicaTop`/`missing`/`apply`/`applyRows`/`shown`/`blank`, `takeMarks` (`marksOf` stays, private: the tests compare two terminals by it), the State's `changes` (a version's counter for the tracks), `read` with `markRead`/`wasRead`/`clearRead` (the rows a step read, for the fills), and `resize_to` with `resizeDeferred` and `resize`'s `later` (screen state's authority sized its terminals after a step's unit); abi/term.zig loses the `Encoder`/`Track`/`Replica` handles, `flight_bound`, `Peer`, `Applied` and those entries of `Ops` (and `dumpScreen`, which nothing in the core called); core/Term.zig its wrappers; core/term/term.zig its ops, its handle map and its `screen_state` export; core/panes.zig its `resizeDeferred` and resizes now (its later screen-state lines go in piece 6); core/edit.zig its `markRead`; the cell-for-cell dump the soak compares a client's terminal with its session's by moves to terminal.zig (`dumpScreen`, over the emulator), the soak's three streams (a shell's, a full-screen program's, `yes`) into test/replicas.zig, their one user; test/terminal.zig loses `a replica's terminal pane draws as its authority's does` (a delta's) and `a terminal made fresh has no size waiting` (`resize_to`'s); core-test 911/1068 (157 skipped), shell-test 1110/1113, term-test 15/15, pane-test 181/182 (again after the machines reboot, on a wiped cache), the soaks small run and `--echo` rc 0
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test/terminal.zig')
| -rw-r--r-- | test/terminal.zig | 95 |
1 files changed, 2 insertions, 93 deletions
diff --git a/test/terminal.zig b/test/terminal.zig index ec050c7a..7e7106a1 100644 --- a/test/terminal.zig +++ b/test/terminal.zig @@ -1,6 +1,6 @@ //! The terminal through the core (docs/next-terminal.md, Phase 1): what -//! were core/term/terminal.zig's and screen_state.zig's tests of a terminal -//! pane, moved as they were. They boot a core and read the emulator behind +//! were core/term/terminal.zig's tests of a terminal pane, moved as they +//! were. They boot a core and read the emulator behind //! it, so they need both modules, which only a suite outside both has: //! pane-test's (test/panes.zig). The emulator's own tests stay in core/term/. const std = @import("std"); @@ -9,12 +9,6 @@ const plain = @import("plain"); const term = @import("term"); const ghostty_vt = @import("ghostty-vt"); const emu = term.terminal; -const screen_state = term.screen_state; -const Encoder = screen_state.Encoder; -const Track = screen_state.Track; -const Peer = screen_state.Peer; -const Replica = screen_state.Replica; -const encode = screen_state.encode; const Surface = pardes.Surface; const Pane = pardes.Pane; const FilterPalette = Term.FilterPalette; @@ -100,39 +94,6 @@ test "replay ownership is terminal-only and construction rolls back on allocatio try std.testing.checkAllAllocationFailures(std.testing.allocator, Case.run, .{true}); } -test "a terminal made fresh has no size waiting: one never resized keeps its grid when a unit is cut" { - // Fresh memory as a Debug build's allocator hands it out: 0xAA. A field - // `create` left unset read a size of 43690x43690 (fixer 2's, 2026-10-30). - const Filling = struct { - child: std.mem.Allocator, - fn alloc(ctx: *anyopaque, len: usize, a: std.mem.Alignment, ra: usize) ?[*]u8 { - const self: *@This() = @ptrCast(@alignCast(ctx)); - const ptr = self.child.rawAlloc(len, a, ra) orelse return null; - @memset(ptr[0..len], 0xAA); - return ptr; - } - fn grow(ctx: *anyopaque, buf: []u8, a: std.mem.Alignment, n: usize, ra: usize) bool { - const self: *@This() = @ptrCast(@alignCast(ctx)); - return self.child.rawResize(buf, a, n, ra); - } - fn remap(ctx: *anyopaque, buf: []u8, a: std.mem.Alignment, n: usize, ra: usize) ?[*]u8 { - const self: *@This() = @ptrCast(@alignCast(ctx)); - return self.child.rawRemap(buf, a, n, ra); - } - fn free(ctx: *anyopaque, buf: []u8, a: std.mem.Alignment, ra: usize) void { - const self: *@This() = @ptrCast(@alignCast(ctx)); - self.child.rawFree(buf, a, ra); - } - const vtable: std.mem.Allocator.VTable = .{ .alloc = alloc, .resize = grow, .remap = remap, .free = free }; - }; - var filling: Filling = .{ .child = std.testing.allocator }; - const gpa: std.mem.Allocator = .{ .ptr = &filling, .vtable = &Filling.vtable }; - const pane = try panes.createTerminal(gpa, 40, 12); - defer gpa.destroy(pane); - defer if (pane.terminal) |state| close(state, gpa); - try std.testing.expect(of(pane.terminal.?).resize_to == null); -} - test "document construction allocates only the pane and has inert terminal defaults" { var failing = std.testing.FailingAllocator.init(std.testing.allocator, .{ .fail_index = 1 }); const allocator = failing.allocator(); @@ -926,55 +887,3 @@ test "colors.xterm is the palette the emulator starts from, all 256" { for (pardes.colors.xterm, ghostty_vt.color.default) |ours, its| try std.testing.expectEqual(ours, [3]u8{ its.r, its.g, its.b }); } -test "a replica's terminal pane draws as its authority's does" { - const testing = std.testing; - const gpa = testing.allocator; - const a = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 60, .rows = 16 }); - defer a.deinit(); - const b = try pardes.Pardes.init(gpa, .{ .tty_only = true, .cols = 60, .rows = 16 }); - defer b.deinit(); - while (a.nextEffect()) |_| {} - while (b.nextEffect()) |_| {} - var fa = std.heap.ArenaAllocator.init(gpa); - defer fa.deinit(); - var fb = std.heap.ArenaAllocator.init(gpa); - defer fb.deinit(); - // Laid out once, so both panes have their size before the first delta. - _ = try a.render(fa.allocator()); - _ = try b.render(fb.allocator()); - const ta = &of(a.panes[0].?.terminal.?).vt; - const tb = &of(b.panes[0].?.terminal.?).vt; - var enc: Encoder = .init(gpa); - defer enc.deinit(); - var peer: Peer = .{}; - defer peer.deinit(gpa); - var tr: Track = .init(gpa); - defer tr.deinit(gpa, ta); - var rep: Replica = .{}; - defer rep.deinit(gpa); - var delta: std.Io.Writer.Allocating = .init(gpa); - defer delta.deinit(); - var line: [256]u8 = undefined; - for (0..60) |i| { - const bytes = try std.fmt.bufPrint(&line, "\x1b[1;3{d}m{d}\x1b[0m 漢字 e\u{301} \x1b[48;2;{d};40;60mbg\x1b[0m and then some text that wraps past the width of the pane\r\n", .{ i % 8, i, i * 4 % 256 }); - a.update(.{ .output = .{ .pane = .at(0), .bytes = bytes } }); - delta.clearRetainingCapacity(); - try testing.expect(try encode(&enc, &tr, &peer, ta, @intCast(i + 1), "", &delta.writer)); - peer.ack((try rep.apply(gpa, std.Io.Threaded.global_single_threaded.io(), tb, delta.written())).seq); - b.needs_frame = true; - _ = fa.reset(.retain_capacity); - _ = fb.reset(.retain_capacity); - const sa = try a.render(fa.allocator()); - const sb = try b.render(fb.allocator()); - const r = a.view().rects[0]; - // The body: below the pane's tag row. - for (r.y + 1..r.y + r.h) |y| for (r.x..r.x + r.w) |x| { - const ca = sa.at(@intCast(x), @intCast(y)); - const cb = sb.at(@intCast(x), @intCast(y)); - if (!ca.visuallyEqual(cb)) { - std.debug.print("step {d}: cell {d},{d}: '{s}' vs '{s}'\n", .{ i, x, y, ca.grapheme(), cb.grapheme() }); - return error.ReplicaDrawsDifferently; - } - }; - } -} |
