Authentic GW-BASIC screen editor with 25x80 buffer, free cursor movement, enter-on-any-line, F1-F10 function keys, Insert/Overwrite toggle, KEY ON/OFF/LIST statement, and Ctrl+Break handling. HAL pointer swap routes all PRINT/LIST/error output through the TUI automatically. Piped mode unchanged (50/50 tests pass). Adds automated compatibility testing infrastructure: DOSBox-X headless config, PRINT-to-file transform script, and run_compat.sh with --generate and --compare modes for verifying output against real GWBASIC.EXE. Project renamed from gwbasic-c to GW-BASIC 2026.
60 lines
1.7 KiB
Bash
Executable File
60 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
# Run all .bas test programs and report results.
|
|
# If .expected files exist, also compare output against them.
|
|
set -u
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
GWBASIC="${PROJECT_DIR}/build/gwbasic"
|
|
EXPECTED_DIR="${SCRIPT_DIR}/expected"
|
|
|
|
if [ ! -x "$GWBASIC" ]; then
|
|
echo "ERROR: gwbasic not found at $GWBASIC (run cmake/make first)"
|
|
exit 1
|
|
fi
|
|
|
|
pass=0
|
|
fail=0
|
|
compat_pass=0
|
|
compat_fail=0
|
|
|
|
for bas in "$SCRIPT_DIR"/programs/*.bas; do
|
|
name="$(basename "$bas")"
|
|
stem="${name%.bas}"
|
|
# chain_target.bas is not standalone
|
|
[ "$name" = "chain_target.bas" ] && continue
|
|
|
|
actual=$(mktemp)
|
|
if timeout 5 "$GWBASIC" "$bas" > "$actual" 2>&1; then
|
|
printf " PASS %s" "$name"
|
|
pass=$((pass + 1))
|
|
|
|
# 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"
|
|
else
|
|
printf " FAIL %s\n" "$name"
|
|
fail=$((fail + 1))
|
|
fi
|
|
rm -f "$actual"
|
|
done
|
|
|
|
echo ""
|
|
echo "$((pass + fail)) tests: $pass passed, $fail failed"
|
|
if [ "$((compat_pass + compat_fail))" -gt 0 ]; then
|
|
echo "Compat: $compat_pass matched, $compat_fail mismatched"
|
|
fi
|
|
[ "$fail" -eq 0 ] || exit 1
|