2026-02-10 16:46:34 -05:00
|
|
|
#!/bin/bash
|
|
|
|
|
# Run all .bas test programs and report results.
|
2026-02-22 12:18:17 -05:00
|
|
|
# If .expected files exist, also compare output against them.
|
2026-02-10 16:46:34 -05:00
|
|
|
set -u
|
|
|
|
|
|
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
|
|
|
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
|
GWBASIC="${PROJECT_DIR}/build/gwbasic"
|
2026-02-22 12:18:17 -05:00
|
|
|
EXPECTED_DIR="${SCRIPT_DIR}/expected"
|
2026-02-10 16:46:34 -05:00
|
|
|
|
|
|
|
|
if [ ! -x "$GWBASIC" ]; then
|
|
|
|
|
echo "ERROR: gwbasic not found at $GWBASIC (run cmake/make first)"
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
pass=0
|
|
|
|
|
fail=0
|
2026-02-22 12:18:17 -05:00
|
|
|
compat_pass=0
|
|
|
|
|
compat_fail=0
|
2026-02-10 16:46:34 -05:00
|
|
|
|
|
|
|
|
for bas in "$SCRIPT_DIR"/programs/*.bas; do
|
|
|
|
|
name="$(basename "$bas")"
|
2026-02-22 12:18:17 -05:00
|
|
|
stem="${name%.bas}"
|
2026-02-22 12:58:47 -05:00
|
|
|
# chain/common targets are not standalone
|
2026-02-10 16:46:34 -05:00
|
|
|
[ "$name" = "chain_target.bas" ] && continue
|
2026-02-22 12:58:47 -05:00
|
|
|
[ "$name" = "common_target.bas" ] && continue
|
2026-02-22 12:18:17 -05:00
|
|
|
|
|
|
|
|
actual=$(mktemp)
|
|
|
|
|
if timeout 5 "$GWBASIC" "$bas" > "$actual" 2>&1; then
|
|
|
|
|
printf " PASS %s" "$name"
|
2026-02-10 16:46:34 -05:00
|
|
|
pass=$((pass + 1))
|
2026-02-22 12:18:17 -05:00
|
|
|
|
|
|
|
|
# Compare against .expected if available
|
|
|
|
|
expected="$EXPECTED_DIR/${stem}.expected"
|
|
|
|
|
if [ -f "$expected" ]; then
|
|
|
|
|
normalized=$(mktemp)
|
|
|
|
|
sed 's/\r//g; s/[[:space:]]*$//' "$actual" | sed '/^$/d' > "$normalized"
|
|
|
|
|
if diff -q "$expected" "$normalized" >/dev/null 2>&1; then
|
|
|
|
|
printf " [compat: ok]"
|
|
|
|
|
compat_pass=$((compat_pass + 1))
|
|
|
|
|
else
|
|
|
|
|
printf " [compat: MISMATCH]"
|
|
|
|
|
compat_fail=$((compat_fail + 1))
|
|
|
|
|
fi
|
|
|
|
|
rm -f "$normalized"
|
|
|
|
|
fi
|
|
|
|
|
printf "\n"
|
2026-02-10 16:46:34 -05:00
|
|
|
else
|
|
|
|
|
printf " FAIL %s\n" "$name"
|
|
|
|
|
fail=$((fail + 1))
|
|
|
|
|
fi
|
2026-02-22 12:18:17 -05:00
|
|
|
rm -f "$actual"
|
2026-02-10 16:46:34 -05:00
|
|
|
done
|
|
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
echo "$((pass + fail)) tests: $pass passed, $fail failed"
|
2026-02-22 12:18:17 -05:00
|
|
|
if [ "$((compat_pass + compat_fail))" -gt 0 ]; then
|
|
|
|
|
echo "Compat: $compat_pass matched, $compat_fail mismatched"
|
|
|
|
|
fi
|
2026-02-10 16:46:34 -05:00
|
|
|
[ "$fail" -eq 0 ] || exit 1
|