summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-23 15:14:30 -0300
committerGabriel Schneider <[email protected]>2026-11-23 15:56:38 -0300
commit36dab7187fa0322c728848532638d549af02f746 (patch)
tree34614c46c9475b3e103e4e266e2b8d76262c0a69 /test
parent62c6caf414fd5a2be556f76eb21d1d6d8d3beadb (diff)
downloadpardes-36dab7187fa0322c728848532638d549af02f746.tar.gz
pardes-36dab7187fa0322c728848532638d549af02f746.zip
upgrade: a window comes back from an Upgrade the size it had (the user's two windows went from 140 x 74 cells to 112 x 32 and from 343 columns to 193 at the 15:11 install): a window session's Upgrade is an exec, and its record said only that there was a window (runtime/upgrade.zig `Record.window`), so the new image made it the default 1120 x 720 points, or the `--geometry` it was started with (its arguments are passed again), never the size the user had given it since; now `upgradeNow` (dev/gui/gui.zig) puts the window's size in points as SDL_GetWindowSize says it then in the record, a line `size WxH` after `window 1` (`Record.size`), and the new image takes it as its `--geometry`, ahead of the one it was started with: the pair's road (a client window's PARDES_JOIN_SIZE, runtime/client.zig `execAgain`, read by the same parse), size only as the pair's (no place: an X11 window started at `+X+Y` is placed by the window manager after an Upgrade now); an older build's record has no such line (the word is passed over by a build before this one): the default, as before; a test window keeps a carried size over PARDES_TEST_COLS and ROWS; test: test/daemon.py `gui_upgrades` resizes the session's window to 100 x 30 cells (the test feed's in-band resize) before the Upgrade and reads the new image's first frame's size from its capture: on the base 1280x840 (80 x 24, the default) where it had been 1600x1050; now 1600x1050 from a build that writes the line, the default from one that does not (the record on the new process's command line says which), and upgrade.zig's record test reads the line back and an older record's none; core-test 934/1100 (166 skipped), shell-test 1142/1145 (3 skipped), gui unit-test 1739/1743 (4 skipped; its perf step's known BaselineHarnessMismatch), test/daemon.py `--upgrade --gui` between this tree's builds (Debug, unstamped and -Dstamp-commit: two semantics) 3/3 and from the installed build (62c6caf414fd) 3/3, `--upgrade` from it 1/1, plain 1/1
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'test')
-rw-r--r--test/daemon.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/test/daemon.py b/test/daemon.py
index f456837b..b9296ea2 100644
--- a/test/daemon.py
+++ b/test/daemon.py
@@ -3995,10 +3995,17 @@ def upgrade_clients(old, new):
shutil.rmtree(root, ignore_errors=True)
+def frame_size(ppm):
+ """A window's capture's width and height in pixels (its P6 header)."""
+ return tuple(int(n) for n in ppm.read_bytes()[:32].split()[1:3])
+
+
def gui_upgrades(old, new):
"""Upgrade in a window session (test mode: hidden windows, captured):
- its window, a client window, an unsaved edit and a shell's job, onto
- another build."""
+ its window, resized since its start, a client window, an unsaved edit
+ and a shell's job, onto another build; its new window the size the old
+ one had when its record names it (upgrade.zig `Record.size`), the
+ default when an older build's names none."""
scratch = Path(__file__).resolve().parent.parent.parent / '.scratch' / 'daemon' / 'dmn'
root = Path(tempfile.mkdtemp(prefix='rtgu-', dir=scratch))
env = base_env()
@@ -4042,12 +4049,19 @@ def gui_upgrades(old, new):
started.append(second.pid)
frames = [caps / 'latest.ppm', root / 'second' / 'latest.ppm']
wait_for('both windows drawn', lambda: all(f.exists() for f in frames), timeout=20)
+ # The window resized by hand since its start (the test feed's
+ # in-band resize, CSI 48;rows;cols t, as a user's drag).
+ start = frame_size(frames[0])
+ os.write(feed_w, b'\x1b[48;30;100t')
+ wait_for('the window resized', lambda: frame_size(frames[0]) != start)
+ sized = frame_size(frames[0])
install(new, binary)
time.sleep(.05)
mark = time.time()
client.write(f'/pane/{shell}/exec', b'Upgrade\n')
client.socket.close()
wait_for('the session on the new build', lambda: exe_of(proc.pid) == (str(binary), True), timeout=30)
+ exec_at = time.time()
client = reconnect(sock)
assert proc.poll() is None
wait_for('the daemon on the new build', lambda: exe_of(daemon) == (str(binary), True))
@@ -4070,6 +4084,17 @@ def gui_upgrades(old, new):
second.p.wait(timeout=30)
said = second.err.read_bytes()
assert b'upgrade this client too' in said or b'run the same pardes at both ends' in said, said[-400:]
+ # The new build's window (a frame captured since the exec) the size
+ # the old one had at the Upgrade, not the one it started at, when
+ # the old build's record (the new process's command line) names it;
+ # an older build's names none: the default.
+ wait_for('a frame of the new build\'s window', lambda: frames[0].stat().st_mtime > exec_at)
+ record = next((a for a in cmdline(proc.pid) if a.startswith(b'--upgraded=')), b'')
+ size = re.search(rb'\nsize (\S+)\n', record)
+ back = frame_size(frames[0])
+ assert back == (sized if size else start), ('the window back the size it had' if size else 'the default', back, sized, start, record)
+ print(f'upgrade: the window resized from {start[0]}x{start[1]} to {sized[0]}x{sized[1]} pixels came back '
+ + (f'that size (its record: size {size[1].decode()})' if size else 'at the default (the old build\'s record names no size)'))
said = Replica(root / 'pardes-replica.sock').hello('win', semantics(new))
assert said == ('welcome', proc.pid, 'win'), said
os.kill(sleeper, signal.SIGTERM)