Files
loc_az_hci/scripts/test/run-all-tests.sh
defiQUG c39465c2bd
Some checks failed
Test / test (push) Has been cancelled
Initial commit: loc_az_hci (smom-dbis-138 excluded via .gitignore)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-08 09:04:46 -08:00

117 lines
2.7 KiB
Bash
Executable File

#!/bin/bash
source ~/.bashrc
# Run All Tests
# Orchestrates all test suites
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
TESTS_DIR="$PROJECT_ROOT/tests"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
log_info() {
echo -e "${GREEN}[INFO]${NC} $1"
}
log_warn() {
echo -e "${YELLOW}[WARN]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
log_test() {
echo -e "${BLUE}[TEST]${NC} $1"
}
run_test_suite() {
local suite_dir=$1
local suite_name=$2
if [ ! -d "$suite_dir" ]; then
log_warn "Test suite directory not found: $suite_dir"
return 0
fi
log_test "Running $suite_name tests..."
local tests_passed=0
local tests_failed=0
while IFS= read -r -d '' test_file; do
if [ -x "$test_file" ]; then
log_info " Running: $(basename "$test_file")"
if "$test_file"; then
tests_passed=$((tests_passed + 1))
log_info " ✓ Passed"
else
tests_failed=$((tests_failed + 1))
log_error " ✗ Failed"
fi
fi
done < <(find "$suite_dir" -name "test-*.sh" -type f -print0)
log_info "$suite_name: $tests_passed passed, $tests_failed failed"
return $tests_failed
}
main() {
echo "========================================="
echo "Running All Test Suites"
echo "========================================="
echo ""
local total_failed=0
# Run E2E tests
if [ -d "$TESTS_DIR/e2e" ]; then
run_test_suite "$TESTS_DIR/e2e" "E2E"
total_failed=$((total_failed + $?))
echo ""
fi
# Run unit tests
if [ -d "$TESTS_DIR/unit" ]; then
run_test_suite "$TESTS_DIR/unit" "Unit"
total_failed=$((total_failed + $?))
echo ""
fi
# Run integration tests
if [ -d "$TESTS_DIR/integration" ]; then
run_test_suite "$TESTS_DIR/integration" "Integration"
total_failed=$((total_failed + $?))
echo ""
fi
# Run performance tests (optional)
if [ -d "$TESTS_DIR/performance" ] && [ "${RUN_PERF_TESTS:-false}" = "true" ]; then
run_test_suite "$TESTS_DIR/performance" "Performance"
total_failed=$((total_failed + $?))
echo ""
fi
echo "========================================="
echo "Test Summary"
echo "========================================="
if [ $total_failed -eq 0 ]; then
log_info "✓ All test suites passed"
exit 0
else
log_error "$total_failed test suite(s) failed"
exit 1
fi
}
main "$@"