forked from preactjs/preact-iso
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_tests.sh
More file actions
executable file
·72 lines (60 loc) · 2.2 KB
/
run_tests.sh
File metadata and controls
executable file
·72 lines (60 loc) · 2.2 KB
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
#!/bin/bash
# Preact ISO URL Pattern Matching - Test Runner
# Runs tests for all language implementations
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m' # No Color
# Track test results
TOTAL_LANGUAGES=4
PASSED_LANGUAGES=0
echo "========================================"
echo "Preact ISO URL Pattern - Test Runner"
echo "========================================"
echo
# Function to run a test and track results
run_test() {
local language=$1
local directory=$2
local command=$3
local description=$4
echo -e "${BLUE}Testing $language${NC} ($description)"
echo "----------------------------------------"
# Change to test directory and run command
if cd "$directory" 2>/dev/null; then
if eval "$command"; then
echo -e "${GREEN}$language tests PASSED${NC}"
((PASSED_LANGUAGES++))
else
echo -e "${RED}$language tests FAILED${NC}"
fi
else
echo -e "${RED}$language tests FAILED - Directory not found${NC}"
fi
echo
# Return to script directory
cd "$SCRIPT_DIR" 2>/dev/null || true
}
# Get the script directory to ensure we're in the right place
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
# Run tests for each language
run_test "Go" "go" "go test -v" "Static typing with struct returns"
run_test "Python" "python" "python3 test_preact_iso_url_pattern.py" "Dictionary-based with optional typing"
run_test "Ruby" "ruby" "ruby test_preact_iso_url_pattern.rb" "Hash-based with flexible syntax"
run_test "PHP" "php" "php test_preact_iso_url_pattern.php" "Mixed array/object approach"
# Summary
echo "========================================"
echo "Test Summary"
echo "========================================"
if [ $PASSED_LANGUAGES -eq $TOTAL_LANGUAGES ]; then
echo -e "${GREEN}All $TOTAL_LANGUAGES language implementations passed their tests!${NC}"
echo -e "${GREEN}Total tests across all languages: 204 (51 × 4)${NC}"
exit 0
else
echo -e "${RED}$PASSED_LANGUAGES/$TOTAL_LANGUAGES language implementations passed${NC}"
echo -e "${RED}$(($TOTAL_LANGUAGES - $PASSED_LANGUAGES)) language(s) failed${NC}"
exit 1
fi