about summary refs log tree commit diff stats
path: root/awk/rawk/tests/test_runner.sh
diff options
context:
space:
mode:
Diffstat (limited to 'awk/rawk/tests/test_runner.sh')
-rwxr-xr-xawk/rawk/tests/test_runner.sh100
1 files changed, 100 insertions, 0 deletions
diff --git a/awk/rawk/tests/test_runner.sh b/awk/rawk/tests/test_runner.sh
new file mode 100755
index 0000000..d0b316d
--- /dev/null
+++ b/awk/rawk/tests/test_runner.sh
@@ -0,0 +1,100 @@
+#!/bin/bash
+
+echo "a rawking test runner"
+echo "=================================="
+
+# Colors for output
+RED='\033[0;31m'
+GREEN='\033[0;32m'
+NC='\033[0m' # No Color
+
+# Test counter
+PASSED=0
+FAILED=0
+TOTAL=0
+
+# Function to run a test
+run_test() {
+    local test_file="$1"
+    local test_name="$2"
+    
+    echo -n "Testing $test_name... "
+    
+    # Step 1: Compile
+    awk -f ../rawk.awk "$test_file" > temp_output.awk
+    
+    # Step 2: Run with input
+    output=$(echo "test input" | awk -f temp_output.awk 2>&1)
+    exit_code=$?
+    
+    if [ $exit_code -eq 0 ]; then
+        echo -e "${GREEN}✓ PASS${NC}"
+        ((PASSED++))
+    else
+        echo -e "${RED}✗ FAIL${NC}"
+        echo "   Output: $output"
+        ((FAILED++))
+    fi
+    
+    ((TOTAL++))
+    rm -f temp_output.awk
+}
+
+# Function to run an error test (should fail)
+run_error_test() {
+    local test_file="$1"
+    local test_name="$2"
+    
+    echo -n "Testing $test_name (should fail)... "
+    
+    output=$(awk -f ../rawk.awk "$test_file" 2>&1)
+    exit_code=$?
+    
+    if [ $exit_code -ne 0 ]; then
+        echo -e "${GREEN}✓ PASS (correctly failed)${NC}"
+        ((PASSED++))
+    else
+        echo -e "${RED}✗ FAIL (should have failed)${NC}"
+        echo "   Output: $output"
+        ((FAILED++))
+    fi
+    
+    ((TOTAL++))
+}
+
+# Run all tests
+echo ""
+echo "Running basic functionality tests..."
+run_test "test_basic.rawk" "Basic Functionality"
+
+echo ""
+echo "Running simple standard library tests..."
+run_test "simple_stdlib_test.rawk" "Simple Standard Library"
+
+echo ""
+echo "Running full standard library tests..."
+run_test "test_stdlib.rawk" "Full Standard Library"
+
+echo ""
+echo "Running functional programming tests..."
+run_test "test_functional.rawk" "Functional Programming"
+
+echo ""
+echo "Running error handling tests..."
+run_error_test "test_errors.rawk" "Error Handling"
+
+# Summary
+echo ""
+echo "=================================="
+echo "Test Summary:"
+echo "   Total tests: $TOTAL"
+echo -e "   ${GREEN}Passed: $PASSED${NC}"
+echo -e "   ${RED}Failed: $FAILED${NC}"
+
+if [ $FAILED -eq 0 ]; then
+    echo -e "\n${GREEN}All tests passed!${NC}"
+    exit 0
+else
+    echo -e "\n${RED}Some tests failed!${NC}"
+    exit 1
+fi 
\ No newline at end of file