unit-test-flake-hunter.sh
1 #!/bin/bash 2 3 # Check if pkg and case variables are provided. 4 if [ $# -lt 2 ] || [ $# -gt 3 ]; then 5 echo "Usage: $0 <pkg> <case> [timeout]" 6 exit 1 7 fi 8 9 pkg=$1 10 case=$2 11 timeout=${3:-30s} # Default to 30s if not provided. 12 13 counter=0 14 15 # Run the command in a loop until it fails. 16 while output=$(go clean -testcache && make unit-debug log="stdlog trace" pkg=$pkg case=$case timeout=$timeout 2>&1); do 17 ((counter++)) 18 echo "Test $case passed, count: $counter" 19 done 20 21 # Only log the output when it fails. 22 echo "Test $case failed. Output:" 23 echo "$output"