diff options
| author | Peter Geissler <peter@haxx.in> | 2026-08-26 16:44:40 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-26 16:48:17 +0200 |
| commit | 4c1f7f8ebd47ac7906ba9629fc67b53fd317fb5f (patch) | |
| tree | d5f8141fc0fab5c073bf86bc0b3f36f9c79d7c5b | |
| parent | a client that stops reading must not stop the session (diff) | |
| download | slosh-4c1f7f8ebd47ac7906ba9629fc67b53fd317fb5f.tar.gz slosh-4c1f7f8ebd47ac7906ba9629fc67b53fd317fb5f.tar.xz slosh-4c1f7f8ebd47ac7906ba9629fc67b53fd317fb5f.zip | |
tests: the greeting is not what the reattach test is about
"reattaching repaints the whole screen" greps the client's byte stream
for the text a pane was holding, and failed about half the time.
The splash assembles from particles scattered over the entire screen, so
for the first few hundred milliseconds of an attach any cell can be
holding a fragment of the logo. The full repaint that a reattach
triggers goes out during exactly that window, so it can carry
│marker-alp▄a
with a particle where the "h" should be. What restores that cell when
the greeting ends is a one-cell diff, cursor-addressed, so the string is
never contiguous in the stream again and the substring check fails.
Nothing about slosh is wrong here -- the model has the text throughout,
and `snapshot text` shows it -- so the fix is to stop asking this file to
assert about the bytes of an animation it is not testing. The session
under test gets a config with splash_ms 0. The greeting has test_splash.
5/5 where it was roughly half.
| -rw-r--r-- | tests/test_session.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/test_session.py b/tests/test_session.py index 5f7bd84..7c3f22b 100644 --- a/tests/test_session.py +++ b/tests/test_session.py @@ -13,6 +13,7 @@ import signal import struct import subprocess import sys +import tempfile import termios import time import uuid @@ -22,6 +23,19 @@ BIN = os.environ.get( os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "build", "slosh"), ) +# No greeting, because this file asserts on the bytes a client is sent. +# +# The splash assembles from particles scattered over the whole screen, so for +# its first few hundred milliseconds any cell can be holding a fragment of the +# logo -- including a cell of the pane text a reattach is supposed to repaint. +# The full repaint then goes out *with* a particle sitting in the middle of +# "marker-alpha", and what restores that cell afterwards is a one-cell diff, so +# the string is never contiguous in the stream and a substring check fails about +# half the time. The greeting has its own tests; here it is noise. +CONFIG = os.path.join(tempfile.mkdtemp(prefix="slosh-session-"), "config.kdl") +with open(CONFIG, "w") as f: + f.write("splash_ms 0\n") + fails = 0 @@ -37,7 +51,7 @@ def attach(name, cols=80, rows=24, inner=None): pid, fd = pty.fork() if pid == 0: os.environ["TERM"] = "xterm-ghostty" - os.environ["SLOSH_CONFIG"] = "/nonexistent/slosh.kdl" + os.environ["SLOSH_CONFIG"] = CONFIG args = [BIN, "-s", name] if inner: args += ["--"] + inner |
