From 8630cffdcde59f4cd7a4f9d67d20b835bd432640 Mon Sep 17 00:00:00 2001 From: asmhatre Date: Tue, 4 Aug 2026 17:28:41 +0000 Subject: [PATCH] Add runner that regenerates every documented output --- run-all.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 run-all.sh diff --git a/run-all.sh b/run-all.sh new file mode 100644 index 0000000..9a76ab8 --- /dev/null +++ b/run-all.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +# Compiles the project and runs every example, writing each program's real output +# to docs/output/.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