1+ #! /bin/bash
2+
3+ # Script to run all Python test files individually and report results
4+ echo " Starting comprehensive test execution..."
5+ echo " ======================================"
6+
7+ # Find all test files and store them in an array
8+ TEST_FILES=($( find . -type f -name " *test*.py" | grep -v .venv | sort) )
9+
10+ # Counter for tracking
11+ TOTAL_TESTS=${# TEST_FILES[@]}
12+ PASSED_TESTS=0
13+ FAILED_TESTS=0
14+ SKIPPED_TESTS=0
15+ FAILED_LIST=()
16+
17+ echo " Found $TOTAL_TESTS test files to execute."
18+ echo " "
19+
20+ # Loop through each test file
21+ for i in " ${! TEST_FILES[@]} " ; do
22+ test_file=" ${TEST_FILES[$i]} "
23+ echo " [$(( i+ 1 )) /$TOTAL_TESTS ] Running: $test_file "
24+
25+ # Execute the test
26+ result=$( python -m pytest " $test_file " -v 2>&1 )
27+ exit_code=$?
28+
29+ if [ $exit_code -eq 0 ]; then
30+ # Check if the test passed by looking for "passed" in output
31+ if echo " $result " | grep -q " failed" ; then
32+ echo " ❌ FAILED - has failed tests"
33+ FAILED_TESTS=$(( FAILED_TESTS + 1 ))
34+ FAILED_LIST+=(" $test_file " )
35+ elif echo " $result " | grep -q " passed" ; then
36+ echo " ✅ PASSED"
37+ PASSED_TESTS=$(( PASSED_TESTS + 1 ))
38+ else
39+ echo " ⚠️ SKIPPED or NO TESTS"
40+ SKIPPED_TESTS=$(( SKIPPED_TESTS + 1 ))
41+ fi
42+ else
43+ echo " ❌ FAILED - execution error"
44+ FAILED_TESTS=$(( FAILED_TESTS + 1 ))
45+ FAILED_LIST+=(" $test_file " )
46+ fi
47+
48+ # Show summary of this test run if it has results
49+ if echo " $result " | grep -q " passed\|failed\|skipped" ; then
50+ passed_count=$( echo " $result " | grep -o " [0-9]\+ passed" | head -1 | grep -o " [0-9]\+" )
51+ failed_count=$( echo " $result " | grep -o " [0-9]\+ failed" | head -1 | grep -o " [0-9]\+" )
52+ skipped_count=$( echo " $result " | grep -o " [0-9]\+ skipped" | head -1 | grep -o " [0-9]\+" )
53+
54+ [[ -z " $passed_count " ]] && passed_count=0
55+ [[ -z " $failed_count " ]] && failed_count=0
56+ [[ -z " $skipped_count " ]] && skipped_count=0
57+
58+ echo " Summary: $passed_count passed, $failed_count failed, $skipped_count skipped"
59+ fi
60+ echo " "
61+ done
62+
63+ # Final summary
64+ echo " ======================================"
65+ echo " COMPREHENSIVE TEST EXECUTION COMPLETE"
66+ echo " ======================================"
67+ echo " Total tests executed: $TOTAL_TESTS "
68+ echo " ✅ Passed: $PASSED_TESTS "
69+ echo " ❌ Failed: $FAILED_TESTS "
70+ echo " ⚠️ Skipped/No tests: $SKIPPED_TESTS "
71+ echo " "
72+
73+ if [ $FAILED_TESTS -gt 0 ]; then
74+ echo " Failed tests:"
75+ for failed_test in " ${FAILED_LIST[@]} " ; do
76+ echo " - $failed_test "
77+ done
78+ echo " "
79+ exit 1
80+ else
81+ echo " 🎉 All tests passed!"
82+ exit 0
83+ fi
0 commit comments