#!/usr/bin/env python3 """Regression check for asynchronous redraw after Wayland stops frame callbacks. Requires Weston with its headless backend and --fake-seat support. Runs in a private compositor/runtime; never sends input to the user's desktop or shells. """ import argparse import os from pathlib import Path import re import shutil import socket import struct import subprocess import tempfile import time parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--binary", type=Path, default=Path("target/debug/psyterm")) args = parser.parse_args() binary = args.binary.resolve() if not binary.is_file() or not shutil.which("weston"): parser.error("build psyTerm first and install Weston") runtime = Path(tempfile.mkdtemp(prefix="psyterm-idle-check-")) server_socket = runtime / "server.sock" gui_log = runtime / "gui.log" env = { **os.environ, "XDG_RUNTIME_DIR": str(runtime), "WAYLAND_DISPLAY": "psyterm-test", "SHELL": "/bin/sh", "RUST_LOG": "psyterm::timing=debug", } env.pop("DISPLAY", None) def wait_for(predicate, description, timeout=12): deadline = time.monotonic() + timeout while time.monotonic() < deadline: result = predicate() if result: return result time.sleep(0.025) raise AssertionError(f"Timed out waiting for {description}; logs: {runtime}") def control(*arguments): return subprocess.check_output( [str(binary), "--socket", str(server_socket), *arguments], env=env, cwd=runtime, text=True, timeout=10, ) def read_exact(stream, count): result = b"" while len(result) < count: chunk = stream.recv(count - len(result)) if not chunk: raise EOFError("server disconnected") result += chunk return result def read_frame(stream): return read_exact(stream, struct.unpack("