Commit 2f2d9790

2f2d97908478Merged

Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 1 file · ~1 modified

Description

test: show running test name on a single line (TTY only)

Long test runs were silent on slow machines, leaving no way to tell whether the harness was working or wedged. Print the current test as [N/total] name on a TTY, overwriting the line each iteration so PASS doesn't scroll. FAIL / ERR clear the progress line first so their messages stay readable. Non-TTY (pipe / CI) keeps the old behavior — only summary and FAIL/ERR lines.

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Details

Commit
2f2d97908478
Parent
be42e99b21ce

MakefilemodifiedView file

@@ -190,9 +190,13 @@
190190
191191 test: spinel_parse$(EXE) $(SP_RT_LIB) spinel_codegen$(EXE)
192192 @if [ -z "$(TIMEOUT_BIN)" ]; then echo "Note: no 'timeout' command found; running without time limits."; fi
193- @pass=0; fail=0; err=0; \
193+ @total=$$(ls test/*.rb | wc -l); \
194+ if [ -t 1 ]; then tty=1; else tty=0; fi; \
195+ pass=0; fail=0; err=0; i=0; \
194196 for f in test/*.rb; do \
197+ i=$$((i+1)); \
195198 bn=$$(basename "$$f" .rb); \
199+ if [ "$$tty" = 1 ]; then printf '\r\033[K [%d/%d] %s' "$$i" "$$total" "$$bn"; fi; \
196200 ./spinel_parse$(EXE) "$$f" /tmp/_sp_t.ast 2>/dev/null && \
197201 ./spinel_codegen$(EXE) /tmp/_sp_t.ast /tmp/_sp_t.c 2>/dev/null && \
198202 $(CC) $(CFLAGS) -Werror $(SEC_FLAGS) -Ilib /tmp/_sp_t.c $(SP_RT_LIB) $(LDFLAGS) -lm $(GC_FLAGS) -o /tmp/_sp_t_bin$(EXE) 2>/dev/null; \
@@ -207,14 +211,17 @@
207211 if [ "$$expected" = "$$actual" ]; then \
208212 pass=$$((pass+1)); \
209213 else \
214+ if [ "$$tty" = 1 ]; then printf '\r\033[K'; fi; \
210215 echo "FAIL: $$bn"; \
211216 printf '%s\n%s\n%s\n%s\n' "--- expected ---" "$$expected" "--- actual ---" "$$actual"; \
212217 fail=$$((fail+1)); \
213218 fi; \
214219 else \
220+ if [ "$$tty" = 1 ]; then printf '\r\033[K'; fi; \
215221 echo "ERR: $$bn"; err=$$((err+1)); \
216222 fi; \
217223 done; \
224+ if [ "$$tty" = 1 ]; then printf '\r\033[K'; fi; \
218225 rm -f /tmp/_sp_t.ast /tmp/_sp_t.c /tmp/_sp_t_bin$(EXE); \
219226 echo "Tests: $$pass pass, $$fail fail, $$err error"; \
220227 if [ $$fail -ne 0 ] || [ $$err -ne 0 ]; then exit 1; fi