11#! /bin/bash
22
3- # Exit on error
4- set -e
3+ # Exit on error (disabled to allow all tests to run)
4+ # set -e
55
66# Wait for PostgreSQL to be ready
77echo " Waiting for PostgreSQL to be ready..."
@@ -50,6 +50,8 @@ PKGS=$(go list ./internal/...)
5050
5151PASS_COUNT=0
5252FAIL_COUNT=0
53+ ALL_TEST_OUTPUT=" "
54+ FAIL_OUTPUTS=" "
5355
5456for PKG in $PKGS ; do
5557 echo -e " \n=== Running tests in $PKG ==="
@@ -60,18 +62,32 @@ for PKG in $PKGS; do
6062 fi
6163 for test in $TESTS ; do
6264 echo -e " \n--- Running $test in $PKG ---"
63- if go test -v -run " ^$test $" $PKG ; then
65+ TEST_OUTPUT=$( go test -v -run " ^$test $" $PKG )
66+ echo " $TEST_OUTPUT "
67+ ALL_TEST_OUTPUT=" $ALL_TEST_OUTPUT \n$TEST_OUTPUT "
68+ if echo " $TEST_OUTPUT " | grep -q ' ^--- PASS' ; then
6469 PASS_COUNT=$(( PASS_COUNT+ 1 ))
6570 else
6671 FAIL_COUNT=$(( FAIL_COUNT+ 1 ))
72+ FAIL_OUTPUTS=" $FAIL_OUTPUTS \n\n===== FAILED TEST: $test in $PKG =====\n$TEST_OUTPUT "
6773 fi
6874 done
75+
76+ # Optionally, you can add a small sleep here if needed
77+ # sleep 0.1
78+
6979done
7080
81+ # Count all '=== RUN' lines (including subtests)
82+ RUN_COUNT=$( echo " $ALL_TEST_OUTPUT " | grep ' ^=== RUN' | wc -l)
7183echo -e " \nAll tests completed."
7284echo " Passed: $PASS_COUNT "
7385echo " Failed: $FAIL_COUNT "
86+ echo " Total RUN (including subtests): $RUN_COUNT "
87+
7488if [ " $FAIL_COUNT " -ne 0 ]; then
89+ echo -e " \n\n==================== FAILED TEST OUTPUTS ===================="
90+ echo -e " $FAIL_OUTPUTS "
7591 exit 1
7692fi
7793
0 commit comments