11#! /bin/bash
22# run_tests.sh - Test runner with clean failure summary
33
4- SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd ) "
5- cd " $SCRIPT_DIR "
4+ SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
5+ cd " $SCRIPT_DIR " || exit 1
66
77# Colors
88GREEN=' \033[0;32m'
@@ -31,23 +31,23 @@ print_usage() {
3131
3232while [[ $# -gt 0 ]]; do
3333 case $1 in
34- -f| --filter)
35- FILTER=" $2 "
36- shift 2
37- ;;
38- -t| --type)
39- TEST_TYPE=" $2 "
40- shift 2
41- ;;
42- -h| --help)
43- print_usage
44- exit 0
45- ;;
46- * )
47- echo " Unknown option: $1 "
48- print_usage
49- exit 1
50- ;;
34+ -f | --filter)
35+ FILTER=" $2 "
36+ shift 2
37+ ;;
38+ -t | --type)
39+ TEST_TYPE=" $2 "
40+ shift 2
41+ ;;
42+ -h | --help)
43+ print_usage
44+ exit 0
45+ ;;
46+ * )
47+ echo " Unknown option: $1 "
48+ print_usage
49+ exit 1
50+ ;;
5151 esac
5252done
5353
@@ -110,14 +110,14 @@ if [ "$TEST_TYPE" != "all" ] && [ "$TEST_TYPE" != "minimal" ] && [ "$TEST_TYPE"
110110 specific_output=$( nvim --headless -u tests/minimal/init.lua -c " lua require('plenary.test_harness').test_directory('./$TEST_TYPE ', {minimal_init = './tests/minimal/init.lua'$FILTER_OPTION })" 2>&1 )
111111 specific_status=$?
112112 clean_output " $specific_output "
113-
113+
114114 if [ $specific_status -eq 0 ]; then
115115 echo -e " ${GREEN} ✓ Specific test passed${NC} "
116116 else
117117 echo -e " ${RED} ✗ Specific test failed${NC} "
118118 fi
119119 echo " ------------------------------------------------"
120-
120+
121121 # Use specific test output for failure analysis
122122 unit_output=" $specific_output "
123123 unit_status=$specific_status
131131all_output=" $minimal_output
132132$unit_output "
133133
134- if [ $minimal_status -ne 0 ] || [ $unit_status -ne 0 ] || echo " $all_output " | grep -q " \[31mFail" ; then
134+ if [ $minimal_status -ne 0 ] || [ $unit_status -ne 0 ] || echo " $all_output " | grep -q " \[31mFail.*|| " ; then
135135 echo -e " \n${RED} ======== TEST FAILURES SUMMARY ========${NC} "
136-
136+
137137 # Extract and format failures
138138 failures_file=$( mktemp)
139- echo " $all_output " | grep -B 0 -A 6 " \[31mFail.*||" > " $failures_file "
139+ echo " $all_output " | grep -B 0 -A 6 " \[31mFail.*||" > " $failures_file "
140140 failure_count=$( grep -c " \[31mFail.*||" " $failures_file " )
141-
141+
142142 echo -e " ${RED} Found $failure_count failing test(s):${NC} \n"
143-
143+
144144 # Process the output line by line
145145 test_name=" "
146146 while IFS= read -r line; do
147147 # Remove ANSI color codes
148148 clean_line=$( echo " $line " | sed -E ' s/\x1B\[[0-9;]*[mK]//g' )
149-
149+
150150 if [[ " $clean_line " == * " Fail" * " ||" * ]]; then
151151 # Extract test name
152152 test_name=$( echo " $clean_line " | sed -E ' s/.*Fail.*\|\|\s*(.*)/\1/' )
@@ -161,8 +161,8 @@ if [ $minimal_status -ne 0 ] || [ $unit_status -ne 0 ] || echo "$all_output" | g
161161 # Stack trace details
162162 echo -e " $clean_line "
163163 fi
164- done < " $failures_file "
165-
164+ done < " $failures_file "
165+
166166 rm -f " $failures_file "
167167 exit 1
168168else
0 commit comments