aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
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 /Makefile
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 'Makefile')
-rw-r--r--Makefile44
1 files changed, 33 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index f1618ec..acfcf48 100644
--- a/Makefile
+++ b/Makefile
@@ -10,15 +10,30 @@ VT_OUT := $(VT)/zig-out
VT_LIB := $(VT_OUT)/lib/libghostty-vt.a
VT_INC := $(VT_OUT)/include
-CFLAGS := -std=c23 -O1 -g -Wall -Wextra -Wno-unused-parameter \
+# -MMD -MP emits a .d per object listing the headers it included, so editing a
+# header rebuilds what actually uses it. Without this a header edit rebuilt
+# nothing and the only safe move was `make clean`, which is how a 0.1s build
+# turns into a habit of throwing the whole thing away.
+CFLAGS := -std=c23 -O1 -g -Wall -Wextra -Wno-unused-parameter -MMD -MP \
-I$(VT_INC) -Isrc
LDFLAGS :=
SRC := $(wildcard src/*.c)
OBJ := $(SRC:src/%.c=build/%.o)
+DEPS := $(OBJ:.o=.d)
BIN := build/sl0ppty
-.PHONY: all clean vendor run test test-live test-all smoke help
+# One stamp per python test file. The stamp depends on the file, the harness and
+# the binary, so an untouched test whose binary has not changed does not run
+# again — and `make -j` runs the rest at once, because they are separate
+# processes that share nothing (script mode opens no socket).
+# test_session.py drives a real pty and belongs to test-live; it is only named
+# test_* by history.
+PY_TESTS := $(filter-out test_session.py,$(notdir $(wildcard tests/test_*.py)))
+PY_STAMPS := $(PY_TESTS:%.py=build/.pass-%)
+JOBS ?= $(shell nproc 2>/dev/null || echo 4)
+
+.PHONY: all clean vendor run test retest test-live test-all smoke help
.DEFAULT_GOAL := help
help: ## show this
@@ -56,16 +71,21 @@ SHADER_TEST := build/shader_test
$(SHADER_TEST): tests/shader_test.c src/shader.c src/screen.c src/json.c $(VT_LIB) | build
$(CC) $(CFLAGS) tests/shader_test.c src/shader.c src/screen.c src/json.c $(VT_LIB) -o $@
+build/.pass-%: tests/%.py tests/harness.py $(BIN) | build
+ @cd tests && timeout 300 python3 $(notdir $<) > ../build/.log-$* 2>&1 \
+ || { echo "FAIL $(notdir $<)"; tail -25 ../build/.log-$*; exit 1; }
+ @printf ' ok %-24s %s\n' "$(notdir $<)" "$$(grep -c '^ok' build/.log-$* 2>/dev/null || echo ?) checks"
+ @touch $@
+
test: $(BIN) $(TEST_BIN) $(KDL_TEST) $(SHADER_TEST) ## unit + headless checks (fast)
- ./$(TEST_BIN)
- @echo
- ./$(KDL_TEST)
- @echo
- ./$(SHADER_TEST)
- @echo
- cd tests && python3 test_screen.py && python3 test_layout.py && python3 test_tabs.py && python3 test_osc5577.py && \
- python3 test_responsive.py && python3 test_finder.py && \
- python3 test_config.py && python3 test_layout_files.py && python3 test_drag.py && python3 test_hover.py && python3 test_scroll.py && python3 test_clipboard.py && python3 test_split_ux.py && python3 test_graphics.py && python3 test_pane_title.py && python3 test_shaders.py
+ @./$(TEST_BIN) >/dev/null && ./$(KDL_TEST) >/dev/null && ./$(SHADER_TEST) >/dev/null \
+ && printf ' ok %-24s %s\n' "C unit tests" "3 binaries"
+ @$(MAKE) --no-print-directory -j$(JOBS) $(PY_STAMPS)
+ @printf '\nall green\n'
+
+retest: ## force every python test to run again
+ @rm -f build/.pass-*
+ @$(MAKE) --no-print-directory test
test-live: $(BIN) ## the checks that need a real tty (slow)
python3 tests/live_m0.py
@@ -84,3 +104,5 @@ run: $(BIN) ## build and run
clean: ## remove our build output (not the vendor lib)
rm -rf build
+
+-include $(DEPS)