-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_samples.sh
More file actions
executable file
·88 lines (72 loc) · 2.14 KB
/
test_samples.sh
File metadata and controls
executable file
·88 lines (72 loc) · 2.14 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/bash
# Pascal Sample Files Test Script
# Tests all sample Pascal files to ensure they parse correctly
# set -e # Exit on any error (commented out to continue testing all files)
echo "🧪 Testing Pascal Sample Files with ferropascal"
echo "=============================================="
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Counters
total_files=0
passed_files=0
failed_files=0
# Function to test a single Pascal file
test_pascal_file() {
local pas_file="$1"
local temp_output="/tmp/ferropascal_test_$(basename "${pas_file%.pas}")_$$.rs"
echo -n "Testing $(basename "$pas_file")... "
# Clean up any existing temp file first
rm -f "$temp_output"
# Capture only stderr (errors), let warnings through to /dev/null
if cargo run --bin ferropascal -- "$pas_file" -o "$temp_output" 2>/tmp/ferropascal_error.log >/dev/null; then
echo -e "${GREEN}✅ PASS${NC}"
((passed_files++))
# Clean up generated Rust file
rm -f "$temp_output"
else
echo -e "${RED}❌ FAIL${NC}"
((failed_files++))
echo " Error parsing: $pas_file"
if [ -f "/tmp/ferropascal_error.log" ]; then
echo " $(tail -1 /tmp/ferropascal_error.log)"
fi
fi
((total_files++))
}
# Test all Pascal files in samples directory
echo "📁 Basic Samples:"
for file in samples/basic/*.pas; do
if [ -f "$file" ]; then
test_pascal_file "$file"
fi
done
echo
echo "📁 Intermediate Samples:"
for file in samples/intermediate/*.pas; do
if [ -f "$file" ]; then
test_pascal_file "$file"
fi
done
echo
echo "📁 Advanced Samples:"
for file in samples/advanced/*.pas; do
if [ -f "$file" ]; then
test_pascal_file "$file"
fi
done
echo
echo "📊 Test Summary:"
echo "==============="
echo "Total files tested: $total_files"
echo -e "Passed: ${GREEN}$passed_files${NC}"
echo -e "Failed: ${RED}$failed_files${NC}"
if [ $failed_files -eq 0 ]; then
echo -e "${GREEN}🎉 All tests passed!${NC}"
exit 0
else
echo -e "${RED}💥 Some tests failed!${NC}"
exit 1
fi