- README documents install-from-disk and what actually works today - jaitest prints the recovery steps when a poisoned build cache makes :test report NO-SOURCE, and AGENTS.md records the failure mode
74 lines
2.5 KiB
Bash
Executable File
74 lines
2.5 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Run the test suite and report the JUnit XML, not just the exit code.
|
|
#
|
|
# A green `test` task does not prove tests ran (see AGENTS.md), so this always
|
|
# prints tests/failures/errors per suite and dumps failure messages.
|
|
#
|
|
# Two concurrent Gradle invocations (e.g. an editor/agent running tests in the
|
|
# background at the same time) fight over build/test-results and the loser dies
|
|
# with `java.io.EOFException` or a missing in-progress-results bin. That is an
|
|
# infrastructure failure, not a test failure, so it is retried once.
|
|
#
|
|
# Usage: ./jaitest [gradle args...] e.g. ./jaitest --tests '*Lexer*'
|
|
set -uo pipefail
|
|
|
|
cd "$(dirname "$0")" || exit 1
|
|
|
|
run_gradle() {
|
|
rm -rf build/reports/tests/test
|
|
./jaigradle cleanTest test "$@" 2>&1 | grep -vE '^\[[0-9.]+s\]\[warning\]\[cds\]'
|
|
return "${PIPESTATUS[0]}"
|
|
}
|
|
|
|
run_gradle "$@"
|
|
gradle_status=$?
|
|
|
|
shopt -s nullglob
|
|
xml=(build/test-results/test/*.xml)
|
|
if [ "$gradle_status" -ne 0 ] && [ ${#xml[@]} -eq 0 ]; then
|
|
echo
|
|
echo "!!! no test XML and a failed build — retrying once (concurrent Gradle run?)"
|
|
sleep 3
|
|
run_gradle "$@"
|
|
gradle_status=$?
|
|
xml=(build/test-results/test/*.xml)
|
|
fi
|
|
|
|
echo
|
|
echo "=== JUnit XML ==="
|
|
if [ ${#xml[@]} -eq 0 ]; then
|
|
echo "NO TEST XML PRODUCED — tests did not run."
|
|
echo
|
|
echo "If Gradle reported ':test NO-SOURCE' while the sources clearly exist, the"
|
|
echo "build cache holds a poisoned entry with empty compileTestKotlin outputs"
|
|
echo "(a concurrent build had its outputs deleted mid-run). Recover with:"
|
|
echo
|
|
echo " ./jaigradle --stop"
|
|
echo " rm -rf build .gradle ~/.gradle/caches/build-cache-1"
|
|
echo " ./jaitest"
|
|
exit 1
|
|
fi
|
|
|
|
total=0
|
|
bad=0
|
|
for f in "${xml[@]}"; do
|
|
line=$(sed -n '2p' "$f")
|
|
name=$(sed -nE 's/^<testsuite name="([^"]*)".*/\1/p' <<<"$line")
|
|
t=$(sed -nE 's/.*tests="([0-9]*)".*/\1/p' <<<"$line")
|
|
fa=$(sed -nE 's/.*failures="([0-9]*)".*/\1/p' <<<"$line")
|
|
er=$(sed -nE 's/.*errors="([0-9]*)".*/\1/p' <<<"$line")
|
|
sk=$(sed -nE 's/.*skipped="([0-9]*)".*/\1/p' <<<"$line")
|
|
printf '%-60s tests=%s skipped=%s failures=%s errors=%s\n' "$name" "$t" "$sk" "$fa" "$er"
|
|
total=$((total + t))
|
|
bad=$((bad + fa + er))
|
|
if [ "$fa" != "0" ] || [ "$er" != "0" ]; then
|
|
grep -E '<(failure|error) ' "$f" | head -40
|
|
fi
|
|
done
|
|
|
|
echo "--- total tests=$total failures+errors=$bad gradle_exit=$gradle_status"
|
|
if [ "$total" -eq 0 ] || [ "$bad" -ne 0 ] || [ "$gradle_status" -ne 0 ]; then
|
|
exit 1
|
|
fi
|
|
echo "OK"
|