ruby: Phase 1 parser (+83 tests, 190 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 11s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 11s
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
# Usage:
|
||||
# bash lib/ruby/test.sh # run all tests
|
||||
# bash lib/ruby/test.sh -v # verbose
|
||||
# bash lib/ruby/test.sh tests/tokenizer.sx # single file
|
||||
# bash lib/ruby/test.sh tests/parse.sx # single file
|
||||
|
||||
set -euo pipefail
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
@@ -39,32 +39,39 @@ FAILED_FILES=()
|
||||
for FILE in "${FILES[@]}"; do
|
||||
[ -f "$FILE" ] || { echo "skip $FILE (not found)"; continue; }
|
||||
TMPFILE=$(mktemp)
|
||||
cat > "$TMPFILE" <<EPOCHS
|
||||
(epoch 1)
|
||||
(load "lib/ruby/tokenizer.sx")
|
||||
(epoch 2)
|
||||
(load "$FILE")
|
||||
(epoch 3)
|
||||
(eval "(list rb-test-pass rb-test-fail)")
|
||||
EPOCHS
|
||||
# Build epoch sequence: load runtime files, then test file, then eval summary.
|
||||
{
|
||||
echo "(epoch 1)"
|
||||
echo "(load \"lib/ruby/tokenizer.sx\")"
|
||||
if [ -f "lib/ruby/parser.sx" ]; then
|
||||
echo "(epoch 2)"
|
||||
echo "(load \"lib/ruby/parser.sx\")"
|
||||
fi
|
||||
echo "(epoch 3)"
|
||||
echo "(load \"$FILE\")"
|
||||
echo "(epoch 4)"
|
||||
echo "(eval \"(list rb-test-pass rb-test-fail)\")"
|
||||
} > "$TMPFILE"
|
||||
|
||||
OUTPUT=$(timeout 60 "$SX_SERVER" < "$TMPFILE" 2>&1 || true)
|
||||
rm -f "$TMPFILE"
|
||||
|
||||
LINE=$(echo "$OUTPUT" | awk '/^\(ok-len 3 / {getline; print; exit}')
|
||||
# Extract epoch 4 result: (ok-len 4 N)\n<val> or (ok 4 <val>)
|
||||
LINE=$(printf '%s\n' "$OUTPUT" | awk '/^\(ok-len 4 / {getline; print; exit}')
|
||||
if [ -z "$LINE" ]; then
|
||||
LINE=$(echo "$OUTPUT" | grep -E '^\(ok 3 \([0-9]+ [0-9]+\)\)' | tail -1 \
|
||||
| sed -E 's/^\(ok 3 //; s/\)$//')
|
||||
LINE=$(printf '%s\n' "$OUTPUT" \
|
||||
| grep -E '^\(ok 4 \([0-9]+ [0-9]+\)\)' | tail -1 \
|
||||
| sed -E 's/^\(ok 4 //; s/\)$//')
|
||||
fi
|
||||
if [ -z "$LINE" ]; then
|
||||
echo "✗ $FILE: could not extract summary"
|
||||
echo "$OUTPUT" | tail -20
|
||||
printf '%s\n' "$OUTPUT" | grep -v '^(ok ' | tail -10
|
||||
TOTAL_FAIL=$((TOTAL_FAIL + 1))
|
||||
FAILED_FILES+=("$FILE")
|
||||
continue
|
||||
fi
|
||||
P=$(echo "$LINE" | sed -E 's/^\(([0-9]+) ([0-9]+)\).*/\1/')
|
||||
F=$(echo "$LINE" | sed -E 's/^\(([0-9]+) ([0-9]+)\).*/\2/')
|
||||
P=$(printf '%s\n' "$LINE" | sed -E 's/^\(([0-9]+) ([0-9]+)\).*/\1/')
|
||||
F=$(printf '%s\n' "$LINE" | sed -E 's/^\(([0-9]+) ([0-9]+)\).*/\2/')
|
||||
TOTAL_PASS=$((TOTAL_PASS + P))
|
||||
TOTAL_FAIL=$((TOTAL_FAIL + F))
|
||||
if [ "$F" -gt 0 ]; then
|
||||
|
||||
Reference in New Issue
Block a user