Add compatibility test script for third-party Lua projects (issue #24)
Tests lua-TestMore, json.lua, and lume against the Lush binary to verify parser/lexer/runtime changes don't break standard Lua code.
This commit is contained in:
95
test-compat.sh
Executable file
95
test-compat.sh
Executable file
@@ -0,0 +1,95 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
LUSH="${LUSH:-$SCRIPT_DIR/lua}"
|
||||
COMPAT_DIR="$SCRIPT_DIR/compat-tests"
|
||||
|
||||
if [[ "${1:-}" == "--clean" ]]; then
|
||||
rm -rf "$COMPAT_DIR"
|
||||
echo "Cleaned $COMPAT_DIR"
|
||||
fi
|
||||
|
||||
mkdir -p "$COMPAT_DIR"
|
||||
|
||||
# --- Helpers ---
|
||||
|
||||
RESULTS_FILE="$COMPAT_DIR/.results.tmp"
|
||||
FAIL_COUNT=0
|
||||
: > "$RESULTS_FILE"
|
||||
|
||||
run_test() {
|
||||
local name="$1"; shift
|
||||
local logfile="$COMPAT_DIR/$name.log"
|
||||
echo "--- Running $name ---"
|
||||
if "$@" >"$logfile" 2>&1; then
|
||||
echo "$name|PASS" >>"$RESULTS_FILE"
|
||||
echo " PASS"
|
||||
else
|
||||
echo "$name|FAIL" >>"$RESULTS_FILE"
|
||||
echo " FAIL (see $logfile)"
|
||||
((FAIL_COUNT++)) || true
|
||||
fi
|
||||
}
|
||||
|
||||
print_summary() {
|
||||
echo ""
|
||||
echo "=== Compatibility Test Results ==="
|
||||
while IFS='|' read -r name status; do
|
||||
printf " %-20s %s\n" "$name" "$status"
|
||||
done <"$RESULTS_FILE"
|
||||
echo ""
|
||||
rm -f "$RESULTS_FILE"
|
||||
}
|
||||
|
||||
clone_or_pull() {
|
||||
local name="$1" url="$2" tag="$3"
|
||||
local dest="$COMPAT_DIR/$name"
|
||||
if [[ -d "$dest" ]]; then
|
||||
echo "--- $name: already cloned ---"
|
||||
else
|
||||
echo "--- Cloning $name @ $tag ---"
|
||||
git clone --depth 1 --branch "$tag" "$url" "$dest"
|
||||
fi
|
||||
}
|
||||
|
||||
# --- Check Lush binary ---
|
||||
|
||||
if [[ ! -x "$LUSH" ]]; then
|
||||
echo "Error: Lush binary not found at $LUSH"
|
||||
echo "Run 'make' first, or set LUSH=/path/to/lua"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Using Lush binary: $LUSH"
|
||||
echo ""
|
||||
|
||||
# === lua-TestMore (TAP test framework) ===
|
||||
|
||||
clone_or_pull "lua-TestMore" "https://framagit.org/fperrad/lua-TestMore.git" "0.3.5"
|
||||
(
|
||||
cd "$COMPAT_DIR/lua-TestMore"
|
||||
export LUA_PATH="$COMPAT_DIR/lua-TestMore/src/?.lua;;"
|
||||
run_test "lua-TestMore" "$LUSH" test/00require.t
|
||||
)
|
||||
|
||||
# === json.lua (JSON encoder/decoder) ===
|
||||
|
||||
clone_or_pull "json.lua" "https://github.com/rxi/json.lua.git" "v0.1.2"
|
||||
(
|
||||
cd "$COMPAT_DIR/json.lua/test"
|
||||
run_test "json.lua" "$LUSH" test.lua
|
||||
)
|
||||
|
||||
# === lume (utility library, 264 tests) ===
|
||||
|
||||
clone_or_pull "lume" "https://github.com/rxi/lume.git" "v2.3.0"
|
||||
(
|
||||
cd "$COMPAT_DIR/lume/test"
|
||||
run_test "lume" "$LUSH" test.lua
|
||||
)
|
||||
|
||||
# === Summary ===
|
||||
|
||||
print_summary
|
||||
exit "$FAIL_COUNT"
|
||||
Reference in New Issue
Block a user