blob: c9e970702a8e28dac408ecee9a4109c43d2ee13f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
#!/bin/bash
set -e
echo "Running rawk Test Suite"
echo "=================================="
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
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... "
output=$(echo "test input" | awk -f ../rawk.awk "$test_file" | awk -f - 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++))
}
# 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)... "
if awk -f ../rawk.awk "$test_file" > /dev/null 2>&1; then
echo -e "${RED}✗ FAIL (should have failed)${NC}"
((FAILED++))
else
echo -e "${GREEN}✓ PASS (correctly failed)${NC}"
((PASSED++))
fi
((TOTAL++))
}
# Run all tests
echo ""
echo "Running basic functionality tests..."
run_test "test_basic.rawk" "Basic Functionality"
echo ""
echo "Running standard library tests..."
run_test "test_stdlib.rawk" "Standard Library"
echo ""
echo "Running functional programming tests..."
run_test "test_functional.rawk" "Functional Programming"
echo ""
echo "Running smart standard library tests..."
run_test "test_smart_stdlib.rawk" "Smart Standard Library"
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
|