1
0

Add runner that regenerates every documented output

This commit is contained in:
2026-08-04 17:28:41 +00:00
parent b618dc17f2
commit 8630cffdcd

27
run-all.sh Normal file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# Compiles the project and runs every example, writing each program's real output
# to docs/output/<ClassName>.txt. Everything checked into docs/output was produced
# by this script — nothing is hand-written.
set -u
cd "$(dirname "$0")"
mvn -B -q clean compile || { echo "compile failed"; exit 1; }
CP="target/classes:$(mvn -B -q dependency:build-classpath -Dmdep.outputFile=/dev/stdout -DincludeScope=runtime 2>/dev/null | tail -1)"
mkdir -p docs/output
FAILED=0
for f in $(find src/main/java -name '*.java' | sort); do
CLASS=$(echo "$f" | sed 's|src/main/java/||; s|\.java$||; s|/|.|g')
grep -q 'public static void main' "$f" || continue
SHORT="${CLASS##*.}"
printf '%-52s' "$SHORT"
if java -cp "$CP" "$CLASS" > "docs/output/$SHORT.txt" 2>&1; then
echo "ok"
else
echo "FAILED"; FAILED=1
fi
done
echo
if [ "$FAILED" -eq 0 ]; then echo "All examples ran successfully."; else echo "Some examples failed."; fi
exit $FAILED