@@ -10,7 +10,8 @@ echo "========================"
1010
1111# Get the directory where this script is located
1212SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) "
13- cd " $SCRIPT_DIR "
13+ PROJECT_ROOT=" $( dirname " $SCRIPT_DIR " ) "
14+ cd " $PROJECT_ROOT "
1415
1516# Initialize counters
1617passed=0
@@ -19,14 +20,20 @@ total_tests=0
1920
2021echo " Searching for test files ending with '.test.sh'..."
2122
22- # Use find with proper handling and avoid command injection
23- while IFS= read -r -d ' ' test_file; do
24- # Skip this script itself
25- if [[ " $( basename " $test_file " ) " == " all.test.sh" ]]; then
23+ # Find and run test files using a simple compatible approach
24+ for test_file in test/* .test.sh; do
25+
26+ # Skip if no files match the pattern
27+ if [[ ! -f " $test_file " ]]; then
28+ continue
29+ fi
30+
31+ # Skip this script itself to prevent infinite recursion
32+ if [[ " $( basename " $test_file " ) " == " $( basename " ${BASH_SOURCE[0]} " ) " ]]; then
2633 continue
2734 fi
2835
29- (( total_tests++ ))
36+ total_tests= $ (( total_tests + 1 ))
3037
3138 echo " Running: $test_file "
3239 echo " ----------------------------------------"
@@ -41,14 +48,14 @@ while IFS= read -r -d '' test_file; do
4148 # while keeping tests isolated from each other and the main script
4249 if ( source " $test_file " ); then
4350 echo " ✓ PASSED: $test_file "
44- (( passed++ ))
51+ passed= $ (( passed + 1 ))
4552 else
4653 echo " ✗ FAILED: $test_file "
47- (( failed++ ))
54+ failed= $ (( failed + 1 ))
4855 fi
4956 echo " "
5057
51- done < <( find . -maxdepth 1 -name ' *.test.sh ' -type f -print0 )
58+ done
5259
5360if [[ " $total_tests " -eq 0 ]]; then
5461 echo " No test files found ending with '.test.sh'"
0 commit comments