Add fast iteration tooling

nix run .#fast, .#test and .#webui-dev; see DEVELOPING.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AeFqV9dZrK6nipHkPfyM4F
This commit is contained in:
2026-10-29 13:34:21 +01:00
co-authored by Claude Sonnet 5.5
parent b9c63273e4
commit 5983eadae2
5 changed files with 223 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
# Runs VM tests one at a time (they need a lot of memory), says what failed.
# router-test NAME... run these tests
# router-test --all run all of them
# router-test -i NAME build the test's interactive driver and run it:
# a Python prompt where start_all(), machine.succeed(...)
# and test_script() work; boot once, retry steps
# router-test --list
# Logs: ${TMPDIR:-/tmp}/router-test-logs/NAME.log
vm_tests="basic pppoe vlans onestick rollback dns installer apply setup update image wireguard"
flake=${FLAKE:-.}
logs=${TMPDIR:-/tmp}/router-test-logs
mkdir -p "$logs"
case ${1:-} in
--list) echo "$vm_tests" | tr ' ' '\n'; exit 0 ;;
-i|--interactive)
[ $# -eq 2 ] || { echo "usage: router-test -i NAME" >&2; exit 2; }
driver=$(nix build --no-link --print-out-paths "$flake#checks.x86_64-linux.$2.driverInteractive")
exec "$driver/bin/nixos-test-driver" --interactive ;;
--all) set -- $vm_tests ;;
""|-*) echo "usage: router-test NAME... | --all | -i NAME | --list" >&2; exit 2 ;;
esac
failed=0
total=$SECONDS
for name in "$@"; do
log=$logs/$name.log
start=$SECONDS
printf '%-12s ' "$name"
if nix build "$flake#checks.x86_64-linux.$name" --max-jobs 1 -L --no-link > "$log" 2>&1; then
printf 'ok %4ds\n' $((SECONDS - start))
else
failed=1
printf 'FAILED %4ds %s\n' $((SECONDS - start)) "$log"
# The failing step and what it said, or the build error before any VM ran.
if grep -aq '!!! Test "' "$log"; then
grep -a -m1 '!!! Test "' "$log" | sed -E 's/^[^>]*> //; s/^/ /' | cut -c1-300
grep -a '!!! ' "$log" | sed -n '2,12p' | sed -E 's/^[^>]*> //; s/^/ /' | cut -c1-240
else
grep -a -E '^error|error:' -A8 "$log" | head -24 | sed 's/^/ /' | cut -c1-240
fi
fi
done
printf '\n%d test(s), %ds\n' $# $((SECONDS - total))
exit $failed