diff options
Diffstat (limited to 'awk/rawk/scratch/tests_old/run_tests.rawk')
-rw-r--r-- | awk/rawk/scratch/tests_old/run_tests.rawk | 163 |
1 files changed, 163 insertions, 0 deletions
diff --git a/awk/rawk/scratch/tests_old/run_tests.rawk b/awk/rawk/scratch/tests_old/run_tests.rawk new file mode 100644 index 0000000..22228a4 --- /dev/null +++ b/awk/rawk/scratch/tests_old/run_tests.rawk @@ -0,0 +1,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" +} \ No newline at end of file |