From 7dbcaa13cc3bebd5470ce1ac3f5e112357564063 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Mon, 23 Nov 2026 09:37:41 -0300 Subject: upgrade: the test that an Upgrade's outcome is said in every view: runtime/upgrade.zig:449 (`load`'s end) set "Upgrade: now ..." or "... it goes on as ..." at `p.view().active`, the live view at the dump, the one whose input came last before the Upgrade's step, not the one that asked (the pair round's `--with-pair --upgrade` ReleaseSafe to Debug 1 of 3: the message on pane 5, a pane of client f's view, which the session's /screen does not show); the unit test (two views, the second's keyboard on a New pane of its own and its input last, dumped and loaded as an upgrade loads it: each view's pane at its keyboard must say "Upgrade: now pardes ") fails at upgrade.zig:493 (logs/t7-upgrade-unfixed.log); and test/daemon.py's refused-upgrade row (two replica clients, the Upgrade written over 9P to the shell's pane) now waits for each client's own screen to say "Upgrade: the new build" Co-Authored-By: Claude Opus Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T --- runtime/upgrade.zig | 34 ++++++++++++++++++++++++++++++++++ test/daemon.py | 3 +++ 2 files changed, 37 insertions(+) diff --git a/runtime/upgrade.zig b/runtime/upgrade.zig index f59117ee..2fa910aa 100644 --- a/runtime/upgrade.zig +++ b/runtime/upgrade.zig @@ -463,6 +463,40 @@ pub fn load(gpa: std.mem.Allocator, core_gpa: std.mem.Allocator, opts: pardes.Op } } +test "an upgrade's outcome is said in every view, at the pane its keyboard is on, whichever view's input came last" { + const gpa = std.testing.allocator; + const p = try pardes.Pardes.init(gpa, .{ .tty_only = true }); + defer p.deinit(); + _ = try p.setTestFile("before the upgrade\n"); + const asked = p.view().active; + // A second client's view, its keyboard on a pane of its own, the input + // that came last its own (as a client's keys before an Upgrade over 9P). + const k = p.openView() orelse return error.NoView; + p.toView(k); + try std.testing.expect(p.executeBuiltinLine(p.view().active, "New")); + try std.testing.expect(p.view().active != asked); + const bytes = try pardes.dump.byteDump(p); + defer gpa.free(bytes); + var tmp = std.testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.writeFile(std.testing.io, .{ .sub_path = "pardes-upgrade-1.dump", .data = bytes }); + var dir_buf: [4096]u8 = undefined; + const dir = dir_buf[0..try tmp.dir.realPath(std.testing.io, &dir_buf)]; + var text_buf: [4300]u8 = undefined; + var rec = try Record.decode(try std.fmt.bufPrint(&text_buf, "link -1\nstub -1\nold -1\nwindow 0\nexe /x/pardes\ndump {s}/pardes-upgrade-1.dump\n", .{dir})); + const q = try load(gpa, gpa, .{ .tty_only = true }, &rec); + defer q.deinit(); + try std.testing.expect(!rec.fresh); + var seen: usize = 0; + for (q.views) |v| if (v) |view| { + const pane = q.panes[view.active].?; + try std.testing.expect(std.mem.startsWith(u8, pane.msg[0..pane.msg_len], "Upgrade: now pardes ")); + seen += 1; + }; + try std.testing.expectEqual(@as(usize, 2), seen); + try std.testing.expect(q.views[0].?.active != q.views[k.index()].?.active); +} + test "an upgrade's record reads back as it was written, and refuses one cut short" { var rec: Record = .{ .link = 5, .stub = 7, .old = 9, .window = true, .exe = "/a b/pardes", .dump = "/home/u/.local/share/pardes/pardes.xitdb", .label = "upgrade-1", .state = .kept }; rec.addPty(3, 1234, 11); diff --git a/test/daemon.py b/test/daemon.py index dc1abcbc..b240b887 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -3561,6 +3561,9 @@ def upgrades(old, new): raise TimeoutError(f'the client joined again: not {[c.stem for _, c in owners if c not in joined]} ' f'{time.monotonic() - t0:.1f} s after the Upgrade, the session back at {back:.1f} s') from None assert again.poll() is None and again5.poll() is None + # The session's news: each client's own screen says it, not only + # the view whose input came last before the Upgrade's step. + wait_for("each client's own screen saying the Upgrade's outcome", lambda: all(b'Upgrade: the new build' in t.text() for t, _ in owners), timeout=15) for (t, check), pane, theirs in zip(owners, mine, reversed(mine)): in_own_view('its own view again', lambda: made_live(t, check), client, pane, theirs) for c, t in ((again, term4), (again5, term5)): -- cgit v1.3