32 lines
1.3 KiB
Bash
Executable File
32 lines
1.3 KiB
Bash
Executable File
#!/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"
|
|
# grep -v strips the sandbox's injected "Picked up JAVA_TOOL_OPTIONS" proxy-config
|
|
# notice from stderr - it is an artifact of this environment, not program output.
|
|
# PIPESTATUS[0] (not grep's own exit code) is what tells us whether java itself failed.
|
|
java -cp "$CP" "$CLASS" 2>&1 | grep -v '^Picked up JAVA_TOOL_OPTIONS' > "docs/output/$SHORT.txt"
|
|
if [ "${PIPESTATUS[0]}" -eq 0 ]; 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
|