#!/bin/bash # This script runs comprehensive automated tests set -e echo "Starting comprehensive automated tests..." # Initialize exit code exit_code=0 # Run unit tests echo "Running unit tests..." if ! go test -v ./... -timeout=30s; then echo "❌ Unit tests failed" exit_code=1 else echo "✅ Unit tests passed" fi # Run tests with race detection echo "Running race condition tests..." if ! go test -race -v ./... -timeout=60s; then echo "❌ Race condition tests failed" exit_code=1 else echo "✅ Race condition tests passed" fi # Run coverage test echo "Running coverage tests..." if ! go test -v -coverprofile=coverage.out ./... -timeout=30s; then echo "❌ Coverage tests failed" exit_code=1 else echo "✅ Coverage tests passed" # Show coverage summary go tool cover -func=coverage.out | tail -n 1 fi # Run benchmarks (to make sure they don't panic) echo "Running benchmarks..." if ! go test -bench=. -run=^$ ./...; then echo "❌ Benchmarks failed" exit_code=1 else echo "✅ Benchmarks passed" fi # Run integration tests (if they exist) echo "Running integration tests..." if [ -n "$(find . -name "*_integration_test.go" -print -quit)" ]; then if ! go test -tags=integration -v ./... -timeout=60s; then echo "❌ Integration tests failed" exit_code=1 else echo "✅ Integration tests passed" fi else echo "ℹ️ No integration tests found" fi # Run property-based tests (if they exist) echo "Running property-based tests..." if [ -n "$(find . -name "*_property_test.go" -print -quit)" ]; then if ! go test -tags=property -v ./... -timeout=60s; then echo "❌ Property-based tests failed" exit_code=1 else echo "✅ Property-based tests passed" fi else echo "ℹ️ No property-based tests found" fi # Run fuzz tests (if they exist) echo "Running fuzz tests..." if [ -n "$(find . -name "*_fuzz_test.go" -print -quit)" ]; then # Run a quick fuzz test to ensure they work go test -fuzz=Fuzz -fuzztime=10s ./pkg/math/ 2>/dev/null || echo "No fuzz tests found in math package" else echo "ℹ️ No fuzz tests found" fi echo "Comprehensive automated tests completed." if [ $exit_code -ne 0 ]; then echo "❌ Some tests failed" exit $exit_code else echo "✅ All tests passed" exit 0 fi