diff --git a/test-runner.sh b/test-runner.sh new file mode 100755 index 0000000..450741e --- /dev/null +++ b/test-runner.sh @@ -0,0 +1,121 @@ +#!/bin/bash +# Test suite runner - Orchestrates all test types +# Copyright © 2026 Known Element Enterprises LLC +# License: GNU Affero General Public License v3.0 only + +set -euo pipefail + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[1;33m' +NC='\033[0m' + +# Test counters +TESTS_RUN=0 +TESTS_PASSED=0 +TESTS_FAILED=0 + +# Logging functions +log_info() { + echo -e "${GREEN}[INFO]${NC} $*" +} + +log_warn() { + echo -e "${YELLOW}[WARN]${NC} $*" +} + +log_error() { + echo -e "${RED}[ERROR]${NC} $*" >&2 +} + +log_success() { + echo -e "${GREEN}[SUCCESS]${NC} $*" +} + +# Function to run a test suite +run_test_suite() { + local suite_name="$1" + local test_path="$2" + shift 2 + + log_info "Running $suite_name test suite..." + + if [[ ! -d "$test_path" ]]; then + log_error "Test path does not exist: $test_path" + ((TESTS_FAILED++)) + return 1 + fi + + if bats -r "$test_path" "$@"; then + log_success "$suite_name tests passed" + ((TESTS_PASSED++)) + return 0 + else + log_error "$suite_name tests failed" + ((TESTS_FAILED++)) + return 1 + fi +} + +# Main function +main() { + local test_type="${1:-all}" + shift || true + + log_info "KNEL-Football Test Suite Runner" + log_info "Test type: $test_type" + + # Run tests based on type + case "$test_type" in + unit) + run_test_suite "Unit" "tests/unit" "$@" + ;; + integration) + run_test_suite "Integration" "tests/integration" "$@" + ;; + security) + run_test_suite "Security" "tests/security" "$@" + ;; + e2e) + run_test_suite "End-to-End" "tests/integration/e2e_test.bats" "$@" + ;; + compliance) + run_test_suite "Compliance" "tests/security/compliance_comprehensive_test.bats" "$@" + ;; + encryption) + run_test_suite "Encryption" "tests/security/encryption_comprehensive_test.bats" "$@" + ;; + all) + ((TESTS_RUN++)) + run_test_suite "Unit" "tests/unit" "$@" + ((TESTS_RUN++)) + run_test_suite "Integration" "tests/integration" "$@" + ((TESTS_RUN++)) + run_test_suite "Security" "tests/security" "$@" + ;; + *) + log_error "Unknown test type: $test_type" + echo "Valid types: unit, integration, security, e2e, compliance, encryption, all" + exit 1 + ;; + esac + + # Print summary + echo "" + log_info "Test Summary" + echo "==============" + echo "Test suites run: $TESTS_RUN" + echo "Test suites passed: $TESTS_PASSED" + echo "Test suites failed: $TESTS_FAILED" + + if [[ $TESTS_FAILED -eq 0 ]]; then + log_success "All test suites passed!" + return 0 + else + log_error "Some test suites failed" + return 1 + fi +} + +main "$@"