tcl: Phase 1 tokenizer — Dodekalogue (52 tests green)
This commit is contained in:
51
lib/tcl/test.sh
Executable file
51
lib/tcl/test.sh
Executable file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tcl-on-SX test runner — epoch protocol to sx_server.exe
|
||||
set -uo pipefail
|
||||
cd "$(git rev-parse --show-toplevel)"
|
||||
|
||||
SX_SERVER="${SX_SERVER:-hosts/ocaml/_build/default/bin/sx_server.exe}"
|
||||
if [ ! -x "$SX_SERVER" ]; then
|
||||
SX_SERVER="/root/rose-ash/hosts/ocaml/_build/default/bin/sx_server.exe"
|
||||
fi
|
||||
if [ ! -x "$SX_SERVER" ]; then echo "ERROR: sx_server.exe not found"; exit 1; fi
|
||||
|
||||
VERBOSE="${1:-}"
|
||||
TMPFILE=$(mktemp)
|
||||
trap "rm -f $TMPFILE" EXIT
|
||||
|
||||
cat > "$TMPFILE" << 'EPOCHS'
|
||||
(epoch 1)
|
||||
(load "lib/tcl/tokenizer.sx")
|
||||
(epoch 2)
|
||||
(load "lib/tcl/tests/parse.sx")
|
||||
(epoch 3)
|
||||
(eval "(tcl-run-parse-tests)")
|
||||
EPOCHS
|
||||
|
||||
OUTPUT=$(timeout 30 "$SX_SERVER" < "$TMPFILE" 2>&1)
|
||||
[ "$VERBOSE" = "-v" ] && echo "$OUTPUT"
|
||||
|
||||
# Result follows an (ok-len 3 N) line
|
||||
RESULT=$(echo "$OUTPUT" | grep -A1 "^(ok-len 3 " | tail -1)
|
||||
if [ -z "$RESULT" ]; then
|
||||
RESULT=$(echo "$OUTPUT" | grep "^(ok 3 " | sed 's/^(ok 3 //' | sed 's/)$//')
|
||||
fi
|
||||
if [ -z "$RESULT" ]; then
|
||||
echo "ERROR: no result from epoch 3"
|
||||
echo "$OUTPUT" | tail -10
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PASSED=$(echo "$RESULT" | grep -o ':passed [0-9]*' | grep -o '[0-9]*$')
|
||||
FAILED=$(echo "$RESULT" | grep -o ':failed [0-9]*' | grep -o '[0-9]*$')
|
||||
PASSED=${PASSED:-0}; FAILED=${FAILED:-1}
|
||||
TOTAL=$((PASSED + FAILED))
|
||||
|
||||
if [ "$FAILED" = "0" ]; then
|
||||
echo "ok $PASSED/$TOTAL tcl-tokenize tests passed"
|
||||
exit 0
|
||||
else
|
||||
echo "FAIL $PASSED/$TOTAL passed, $FAILED failed"
|
||||
echo "$RESULT"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user