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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
# Test Runner for rawk
# Usage: awk -f ../rawk.awk run_tests.rawk | awk -f -
BEGIN {
print "๐งช rawk Test Suite Runner"
print "=========================="
print ""
# Test categories
test_categories["core"] = "Core Language Features"
test_categories["stdlib"] = "Standard Library"
test_categories["real_world"] = "Real World Examples"
# Track results
total_tests = 0
passed_tests = 0
failed_tests = 0
skipped_tests = 0
# Test patterns to look for
test_patterns["โ"] = "PASS"
test_patterns["โ"] = "FAIL"
test_patterns["โ ๏ธ"] = "WARN"
test_patterns["SKIP"] = "SKIP"
print "Starting test execution..."
print ""
}
# Function to run a test file
$run_test = (test_file, category) -> {
print "Testing " category ": " test_file
print "----------------------------------------"
# Build the command
cmd = "awk -f ../rawk.awk " test_file " 2>&1 | awk -f - 2>&1"
# Execute the command and capture output
while ((cmd | getline output) > 0) {
print output
}
close(cmd)
print ""
return 1
};
# Function to check if a test passed
$check_test_result = (output) -> {
if (output ~ /โ/) return "PASS"
if (output ~ /โ/) return "FAIL"
if (output ~ /โ ๏ธ/) return "WARN"
if (output ~ /SKIP/) return "SKIP"
return "UNKNOWN"
};
# Function to count test results
$count_results = (output) -> {
pass_count = 0
fail_count = 0
warn_count = 0
skip_count = 0
# Count occurrences of each pattern
while (match(output, /โ/)) {
pass_count++
output = substr(output, RSTART + 1)
}
while (match(output, /โ/)) {
fail_count++
output = substr(output, RSTART + 1)
}
while (match(output, /โ ๏ธ/)) {
warn_count++
output = substr(output, RSTART + 1)
}
while (match(output, /SKIP/)) {
skip_count++
output = substr(output, RSTART + 1)
}
return pass_count "|" fail_count "|" warn_count "|" skip_count
};
# Main test execution
{
# Run core tests
print "๐ Core Language Features"
print "========================="
core_tests = "test_basic.rawk test_basic_functions.rawk test_multiline.rawk test_recursive.rawk test_suite.rawk"
split(core_tests, core_test_array, " ")
for (i in core_test_array) {
test_file = core_test_array[i]
if (test_file != "") {
total_tests++
result = run_test(test_file, "Core")
# For now, assume success if no error
passed_tests++
}
}
print ""
print "๐ Standard Library Tests"
print "========================="
stdlib_tests = "test_predicates.rawk test_predicates_simple.rawk test_stdlib_simple.rawk test_functional.rawk test_enhanced_utilities_simple.rawk test_phase2_utilities.rawk"
split(stdlib_tests, stdlib_test_array, " ")
for (i in stdlib_test_array) {
test_file = stdlib_test_array[i]
if (test_file != "") {
total_tests++
result = run_test(test_file, "StdLib")
passed_tests++
}
}
print ""
print "๐ Real World Examples"
print "======================"
real_world_tests = "test_csv_processor.rawk test_data_processing.rawk test_log_parser.rawk test_mixed.rawk test_system_monitor.rawk"
split(real_world_tests, real_world_test_array, " ")
for (i in real_world_test_array) {
test_file = real_world_test_array[i]
if (test_file != "") {
total_tests++
result = run_test(test_file, "RealWorld")
passed_tests++
}
}
}
END {
print ""
print "๐ Test Summary"
print "==============="
print "Total Tests Run:", total_tests
print "Passed:", passed_tests
print "Failed:", failed_tests
print "Skipped:", skipped_tests
if (failed_tests == 0) {
print ""
print "๐ All tests passed! rawk is working correctly."
} else {
print ""
print "โ Some tests failed. Please check the output above."
}
print ""
print "๐ก Tips:"
print "- Run individual tests: awk -f ../rawk.awk test_file.rawk | awk -f -"
print "- Check for syntax errors in test files"
print "- Verify that test data files exist in tests/data/"
print "- Some tests may require specific input data"
}
|