aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_split_ux.py
diff options
context:
space:
mode:
authoruser <user@clank>2026-08-14 15:16:06 +0200
committeruser <user@clank>2026-08-14 15:16:06 +0200
commitc20b226d44af64ac476173361dad9676dbc74043 (patch)
tree00a549e550361cd34461fa0393b9cc73fc65543b /tests/test_split_ux.py
parentsl0ppty: the resize hint names the verb (diff)
downloadslosh-c20b226d44af64ac476173361dad9676dbc74043.tar.gz
slosh-c20b226d44af64ac476173361dad9676dbc74043.tar.xz
slosh-c20b226d44af64ac476173361dad9676dbc74043.zip
sl0ppty: the test cycle was 80s, it is now 5.5s
Measured before changing anything, because the obvious suspect was wrong: the build is not slow. zig caches objects, so even a clean rebuild is ~0.15s and an incremental one is 0.08s. The C unit tests are 0.00s. All eighty seconds were in the python suite, and almost all of that was waiting on durations that were guesses. Four things, in order of what they bought. Run the python tests in parallel. They are separate processes that share nothing — script mode opens no socket — so each is now its own make target with a stamp, and `make -j` runs them at once. 78s -> 21s for free. The stamps are worth as much as the parallelism day to day: an untouched test whose binary has not changed does not run again, so `make test` after editing one test file is 1.1s and after editing nothing is 0.02s. The binary is a prerequisite of every stamp, so changing the code still re-runs everything. Then stop guessing at durations. `settle N` is the only thing that reads a pane's pty, so it is how you wait for a program's output — but `send` and `snapshot` are already synchronous with the app, which means a settle after a mouse event, waiting to assert on our own chrome, is waiting for nothing at all. Those are removed. Where a program's output really is the thing being waited for, harness.until()/until_text() polls in 10ms steps and returns the instant it lands: measured, that is one poll, against the 200-300ms those calls used to donate. The default settle drops 120ms -> 20ms on the same reasoning. Three effects are gated on a real clock rather than on anything observable — the hover dwell, and a toast's lifetime. Those genuinely have to wait, so the tests that are not *about* the timing now configure the clock down instead (hover_delay_ms 20, toast_ms 150) and the two tests that are about it keep the real defaults, because a dwell test that cannot observe not-yet-elapsed proves nothing. Two tests turned out to be passing by accident, which is the useful kind of thing a speedup shakes loose: both asserted the resize hint was gone after a drop while the pointer was still sitting on the handle. It was only gone because the dwell had not re-elapsed — resting on a handle *should* re-arm the hint. They now move off the handle first and assert the thing they meant. Unrelated but found on the way: the Makefile tracked no header dependencies, so editing a .h rebuilt nothing and the only safe move was `make clean`. -MMD -MP fixes it; touching shader.h now rebuilds exactly the six objects that include it. That one was a correctness bug wearing a performance costume. .fastfeedback/SPEED.md records the measurements and how to write a fast test here, so the next person does not rediscover that settle-after-a-click is free to delete.
Diffstat (limited to 'tests/test_split_ux.py')
-rw-r--r--tests/test_split_ux.py40
1 files changed, 25 insertions, 15 deletions
diff --git a/tests/test_split_ux.py b/tests/test_split_ux.py
index faa1341..cfbd6e4 100644
--- a/tests/test_split_ux.py
+++ b/tests/test_split_ux.py
@@ -13,12 +13,18 @@ import time
from harness import Session, check, report
+FAST_TEXT = "hover_delay_ms 20\n"
+
+
def cfg(text):
f = tempfile.NamedTemporaryFile("w", suffix=".kdl", delete=False)
f.write(text)
f.close()
return f.name
+
+FAST = cfg(FAST_TEXT)
+
SH = ["/bin/sh", "-c", 'printf "\\033]2;shell\\007"; stty raw -echo; cat']
@@ -27,9 +33,13 @@ def hover(s, x, y):
def rest(s, x, y):
- """Hover and stay there: the guide arms on dwell, not on contact."""
+ """Hover and stay there: the guide arms on dwell, not on contact.
+
+ The wait is real elapsed time - the guide is gated on a clock, not on
+ anything observable - so the sessions that are not *about* the dwell run
+ with FAST_TEXT and pay 20ms instead of 250."""
hover(s, x, y)
- time.sleep(0.35)
+ time.sleep(0.06)
def click(s, x, y):
@@ -38,7 +48,7 @@ def click(s, x, y):
def test_no_more_plus():
- with Session(SH, cols=60, rows=14) as s:
+ with Session(SH, cols=60, rows=14, config=FAST) as s:
s.settle()
snap = s.snapshot()
p = s.pane()
@@ -57,7 +67,7 @@ def test_each_border_splits_toward_itself():
("bottom", lambda p: (p["x"] + 4, p["y"] + p["h"] - 1), "below"),
("top", lambda p: (p["x"] + 4, p["y"]), "above"),
]:
- with Session(SH, cols=80, rows=26) as s:
+ with Session(SH, cols=80, rows=26, config=FAST) as s:
s.settle()
before = s.pane()
x, y = cell(before)
@@ -90,7 +100,7 @@ def test_each_border_splits_toward_itself():
def test_the_guide():
- with Session(SH, cols=80, rows=26) as s:
+ with Session(SH, cols=80, rows=26, config=FAST) as s:
s.settle()
p = s.pane()
snap = s.snapshot()
@@ -127,7 +137,7 @@ def test_guide_follows_the_new_layout():
until the mouse moved and corrected it. It is derived during the paint
now, from the rects that paint registered.
"""
- with Session(SH, cols=120, rows=26) as s:
+ with Session(SH, cols=120, rows=26, config=FAST) as s:
s.settle()
p = s.pane()
edge_x, edge_y = p["x"] + p["w"] - 1, p["y"] + 3
@@ -155,7 +165,7 @@ def test_guide_follows_the_new_layout():
def test_the_guide_waits_for_a_rest():
"""A pointer crossing a border on its way elsewhere must not flash it."""
- with Session(SH, cols=80, rows=26) as s:
+ with Session(SH, cols=80, rows=26, config=FAST) as s:
s.settle()
p = s.pane()
left, right = p["x"], p["x"] + p["w"] - 1
@@ -215,7 +225,7 @@ def test_delay_is_configurable():
def test_guide_is_per_pane():
- with Session(SH, cols=150, rows=26) as s:
+ with Session(SH, cols=150, rows=26, config=FAST) as s:
s.settle()
s.key("\\\\")
s.settle()
@@ -231,7 +241,7 @@ def test_guide_is_per_pane():
def test_drag_still_moves():
"""The top border does double duty: click splits, drag moves."""
- with Session(SH, cols=90, rows=26) as s:
+ with Session(SH, cols=90, rows=26, config=FAST) as s:
s.settle()
s.key("\\\\")
s.settle()
@@ -257,7 +267,7 @@ def test_drag_still_moves():
def test_tiny_panes_have_no_targets():
- with Session(SH, cols=90, rows=16) as s:
+ with Session(SH, cols=90, rows=16, config=FAST) as s:
s.settle()
s.key("\\\\")
s.settle()
@@ -289,7 +299,7 @@ def edge_of(pane, side):
def test_a_split_below_the_floor_is_not_offered():
"""min_split is a usability floor, not the physical one: the pane below
would still *fit* by min_pane, and is refused anyway."""
- conf = cfg("min_pane cols=10 rows=3\nmin_split cols=40 rows=14\n")
+ conf = cfg(FAST_TEXT + "min_pane cols=10 rows=3\nmin_split cols=40 rows=14\n")
with Session(SH, cols=80, rows=26, config=conf) as s:
s.settle()
p = s.pane()
@@ -309,7 +319,7 @@ def test_a_split_below_the_floor_is_not_offered():
def test_the_floor_is_configurable_in_both_axes():
# Wide enough for columns, too short for rows.
- conf = cfg("min_split cols=20 rows=40\n")
+ conf = cfg(FAST_TEXT + "min_split cols=20 rows=40\n")
with Session(SH, cols=90, rows=26, config=conf) as s:
s.settle()
p = s.pane()
@@ -327,7 +337,7 @@ def test_the_floor_is_configurable_in_both_axes():
def test_the_keyboard_obeys_the_same_floor():
- conf = cfg("min_split cols=40 rows=14\n")
+ conf = cfg(FAST_TEXT + "min_split cols=40 rows=14\n")
with Session(SH, cols=80, rows=26, config=conf) as s:
s.settle()
s.key("\\\\")
@@ -343,7 +353,7 @@ def test_the_keyboard_obeys_the_same_floor():
def test_the_guide_says_which_way_it_goes():
- with Session(SH, cols=120, rows=26) as s:
+ with Session(SH, cols=120, rows=26, config=FAST) as s:
s.settle()
p = s.pane()
for side in ("l", "r", "t", "b"):
@@ -358,7 +368,7 @@ def test_the_guide_says_which_way_it_goes():
def test_the_arrow_sits_on_the_new_boundary():
- with Session(SH, cols=120, rows=26) as s:
+ with Session(SH, cols=120, rows=26, config=FAST) as s:
s.settle()
p = s.pane()
x, y = edge_of(p, "r")