#!/usr/bin/env bash # Verify every exercise: the broken version must fail, and the # solution must pass. Run from anywhere; operates on the repo root. set -u cd "$(dirname "$0")/.." export NO_COLOR=1 sbcl --noinform --no-sysinit --no-userinit --disable-debugger \ --eval '(with-open-file (in "info.sexp") (let ((specs (second (assoc :exercises (read in))))) (dolist (s specs) (format t "~a ~a~%" (getf s :dir) (getf s :name)))))' \ --quit > "${TMPDIR:-/tmp}/lisplings-exercise-list.txt" 2>/dev/null fail=0 total=0 while read -r dir name; do total=$((total+1)) sbcl --script src/exercise-runner.lisp "exercises/$dir/$name.lisp" > /dev/null 2>&1 b=$? sbcl --script src/exercise-runner.lisp "solutions/$dir/$name.lisp" > /dev/null 2>&1 s=$? if cmp -s "exercises/$dir/$name.lisp" "solutions/$dir/$name.lisp"; then if [ "$s" -eq 0 ]; then echo "ok $dir/$name (read-only)" else echo "BAD $dir/$name: SOLUTION FAILS ($s)" fail=1 fi else if [ "$b" -ne 0 ] && [ "$s" -eq 0 ]; then echo "ok $dir/$name" else echo "BAD $dir/$name: broken=$b solution=$s" fail=1 fi fi done < "${TMPDIR:-/tmp}/lisplings-exercise-list.txt" echo "----" echo "verified $total exercises" [ $fail -eq 0 ] && echo "ALL EXERCISES VERIFIED" || echo "FAILURES PRESENT" exit $fail