diff options
| author | user <user@clank> | 2026-08-15 13:21:35 +0200 |
|---|---|---|
| committer | user <user@clank> | 2026-08-15 13:21:35 +0200 |
| commit | d24a07a6048e6d6416e97a26483739bdd879e01b (patch) | |
| tree | 764a08f255aeaa71fa8fbdc6bad7fa1b9835171f /tests | |
| parent | sl0ppty: write the session back out as a layout, and a loop that uses it (diff) | |
| download | slosh-d24a07a6048e6d6416e97a26483739bdd879e01b.tar.gz slosh-d24a07a6048e6d6416e97a26483739bdd879e01b.tar.xz slosh-d24a07a6048e6d6416e97a26483739bdd879e01b.zip | |
sl0ppty: say which build you are talking to
The middle of the status line is empty unless the pointer is on something,
which is most of the time. It says which sl0ppty this is now.
That reads as decoration and is not. A session keeps the binary it started
with, so after a rebuild there are two versions in play: the one on disk and
the one you are attached to. This session has been dogfooding sl0ppty for a
while, and "which build is this?" has already been the answer to two bugs
that looked like something else -- once when a config reload appeared to do
nothing, and once when kitty graphics were fixed and still broken on screen.
The banner answers it without asking, and `sl0ppty --version` answers for the
binary, from the same string.
The version is baked in by the Makefile from `git describe --always --dirty`,
into a generated header that is only rewritten when the value changes -- so a
commit rebuilds and a second `make` does nothing.
It takes the hint's slot and yields to it: a hint is about what you are doing
right now, the banner is about always, and it comes back the moment the
pointer moves off. Both give way to the ends of the line, which was already
the rule for hints and is why a narrow terminal loses the middle rather than
its session name. `version_banner false` for anyone who finds it noisy; it is
a separate knob from `hints`, and the tests hold both directions of that.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test_hints.py | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/tests/test_hints.py b/tests/test_hints.py index f39e874..35f9905 100644 --- a/tests/test_hints.py +++ b/tests/test_hints.py @@ -139,6 +139,67 @@ def test_the_hint_never_writes_over_the_line_it_shares(): and "pane 1/1" in row, repr(row)) +def test_the_version_sits_in_the_slot_when_no_hint_does(): + """The middle of the status line is empty most of the time, and the first + question about a misbehaving session is which build it is running — which + is not "whatever was built last", because a session keeps the binary it + started with.""" + with Session(SH, cols=96, rows=18) as s: + s.settle(20) + check("the banner is there by default", "sl0ppty 0." in bar(s), bar(s)) + + s.api("split", dir="cols") + s.settle(20) + h = hit(s, "close:") + hover(s, h["x"], h["y"]) + check("a hint takes the slot back", "close this pane" in bar(s), bar(s)) + check("and the banner gives way", "sl0ppty 0." not in bar(s), bar(s)) + + hover(s, h["x"], h["y"] + 4) # off the button, into the pane + s.settle(20) + check("the banner returns when the pointer moves off", + "sl0ppty 0." in bar(s), bar(s)) + + +def test_the_banner_and_the_hints_are_separate_knobs(): + off = cfg("version_banner false\n") + with Session(SH, cols=96, rows=18, config=off) as s: + s.settle(20) + check("version_banner false says nothing", "sl0ppty" not in bar(s), + bar(s)) + s.api("split", dir="cols") + s.settle(20) + h = hit(s, "close:") + hover(s, h["x"], h["y"]) + check("but hints still work", "close this pane" in bar(s), bar(s)) + os.unlink(off) + + nohints = cfg("hints false\n") + with Session(SH, cols=96, rows=18, config=nohints) as s: + s.settle(20) + check("hints false leaves the banner alone", "sl0ppty 0." in bar(s), + bar(s)) + s.api("split", dir="cols") + s.settle(20) + h = hit(s, "close:") + hover(s, h["x"], h["y"]) + check("and nothing replaces it", "sl0ppty 0." in bar(s), bar(s)) + os.unlink(nohints) + + +def test_the_banner_gives_way_when_there_is_no_room(): + """Same rule as the hint: a thing in the middle that overwrites the ends is + worse than an empty middle.""" + with Session(SH, cols=44, rows=10) as s: + s.settle(20) + s.api("set-purpose", target="tab", id=s.tabs()[0]["id"], + purpose="a-long-purpose-that-fills-the-line") + s.settle(20) + row = bar(s) + check("the ends win", "pane 1/1" in row and "sl0ppty 0." not in row, + repr(row)) + + def test_hints_can_be_turned_off(): conf = cfg("hints false\n") with Session(SH, cols=96, rows=18, config=conf) as s: @@ -159,4 +220,7 @@ if __name__ == "__main__": test_the_gap_and_the_strip_and_the_bar() test_the_hint_never_writes_over_the_line_it_shares() test_hints_can_be_turned_off() + test_the_version_sits_in_the_slot_when_no_hint_does() + test_the_banner_and_the_hints_are_separate_knobs() + test_the_banner_gives_way_when_there_is_no_room() sys.exit(report()) |
