62 lines
1.3 KiB
Bash
62 lines
1.3 KiB
Bash
|
|
#!/bin/bash
|
||
|
|
|
||
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||
|
|
RAVA="$SCRIPT_DIR/../rava"
|
||
|
|
TESTS_DIR="$SCRIPT_DIR/tests"
|
||
|
|
EXAMPLES_DIR="$SCRIPT_DIR/examples"
|
||
|
|
|
||
|
|
RED='\033[0;31m'
|
||
|
|
GREEN='\033[0;32m'
|
||
|
|
YELLOW='\033[1;33m'
|
||
|
|
NC='\033[0m'
|
||
|
|
|
||
|
|
passed=0
|
||
|
|
failed=0
|
||
|
|
|
||
|
|
run_test() {
|
||
|
|
local file="$1"
|
||
|
|
local name=$(basename "$file" .txt)
|
||
|
|
|
||
|
|
echo -n " $name ... "
|
||
|
|
|
||
|
|
if timeout 30 "$RAVA" < "$file" > /tmp/repl_test_output.txt 2>&1; then
|
||
|
|
echo -e "${GREEN}ok${NC}"
|
||
|
|
((passed++))
|
||
|
|
else
|
||
|
|
echo -e "${RED}FAIL${NC}"
|
||
|
|
echo " Output:"
|
||
|
|
head -20 /tmp/repl_test_output.txt | sed 's/^/ /'
|
||
|
|
((failed++))
|
||
|
|
fi
|
||
|
|
}
|
||
|
|
|
||
|
|
echo "========================================"
|
||
|
|
echo "REPL Test Suite"
|
||
|
|
echo "========================================"
|
||
|
|
echo ""
|
||
|
|
|
||
|
|
echo "Running tests..."
|
||
|
|
for test_file in "$TESTS_DIR"/*.txt; do
|
||
|
|
if [ -f "$test_file" ]; then
|
||
|
|
run_test "$test_file"
|
||
|
|
fi
|
||
|
|
done
|
||
|
|
|
||
|
|
echo ""
|
||
|
|
echo "Running examples..."
|
||
|
|
for example_file in "$EXAMPLES_DIR"/*.txt; do
|
||
|
|
if [ -f "$example_file" ]; then
|
||
|
|
run_test "$example_file"
|
||
|
|
fi
|
||
|
|
done
|
||
|
|
|
||
|
|
echo ""
|
||
|
|
echo "========================================"
|
||
|
|
echo "Results: $passed passed, $failed failed"
|
||
|
|
echo "========================================"
|
||
|
|
|
||
|
|
if [ $failed -gt 0 ]; then
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
exit 0
|