dotfiles/claude/tests/run.sh
Jonny Barnes 2a785a55a7
Pace the per-model weekly limit over the days you actually work
The weekly limit resets every 7 days, but a 5-day week means the sustainable
burn is 20% a day, not the 100/7 the calendar implies. Nothing on the line
said that, so staying inside the limit meant doing the division by hand.

Adds pace and trend to the per-model bar: "Fable 6% 19%/d ✓". pace is what
is left divided by the working days still in the window, so it is the
envelope for today. trend compares usage against today's band - during
working day n of m, anywhere between (n-1)/m and n/m of the budget is on
track - and reports the distance outside it.

A band rather than a point because a point built from completed days expects
0% on the first working day of the window, so any usage at all reads as
overspending: 6% on a Monday morning showed a red arrow. The band is also
all whole-day granularity supports, and the sleep-aware glide in
statusline.burnrate.sh is what it would take to say more.

Working days come from SL_WORK_DAYS (ISO weekdays, default Mon-Fri) and are
counted inside the reset window rather than assumed, so a window that starts
mid-week still divides correctly. The colour thresholds derive from
100/total_workdays instead of the hardcoded 14.3-a-day ones in burnrate.sh,
which would call 13%/d healthy against a 20-a-day budget.

SL_NOW is a test seam for the clock. The cache-age checks deliberately stay
on the real clock: a pinned SL_NOW could otherwise age a fresh fixture past
USAGE_CACHE_SECS and send a test to the network with real credentials.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-02 21:02:47 +01:00

28 lines
920 B
Shell
Executable file

#!/bin/bash
# Run every test for claude/statusline.isaacaudet.sh.
#
# Usage: claude/tests/run.sh
#
# The tests render the status line directly, so they need the same tools it
# does (bash, jq, git, python3). They point STATUSLINE_CACHE_DIR at a temporary
# directory and write their fixtures there, so the caches the live status line
# reads are never touched.
cd "$(dirname "${BASH_SOURCE[0]}")" || exit 1
status=0
for t in statusline.isaacaudet.payload_test.sh \
statusline.isaacaudet.thinking_test.sh \
statusline.isaacaudet.width_test.sh \
statusline.isaacaudet.pace_test.sh \
statusline.isaacaudet.cache_test.sh; do
echo "== $t"
bash "$t" || status=1
echo
done
echo "== statusline.isaacaudet.overflow_test.py"
python3 statusline.isaacaudet.overflow_test.py || status=1
echo
[ "$status" -eq 0 ] && echo "ALL TESTS PASSED" || echo "SOME TESTS FAILED"
exit "$status"