#!/bin/bash # TSYS FetchApply Testing Framework # Main test runner script set -euo pipefail # Resolve repository root from this script's location (Project-Tests/ -> repo root) PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # The KNELShellFramework is vendored under vendor/ FRAMEWORK_INCLUDES="$PROJECT_ROOT/vendor/git@git.knownelement.com/29418/KNEL/KNELShellFramework/Framework-Includes" source "$FRAMEWORK_INCLUDES/Logging.sh" source "$FRAMEWORK_INCLUDES/PrettyPrint.sh" # The vendored PrettyPrint only defines print_info/print_error; provide the # additional output helpers the test suite relies on. function print_header() { echo ""; echo "=== $1 ==="; } function print_success() { echo "✅ $1"; } function print_warning() { echo "⚠️ $1"; } # Test configuration TEST_LOG_DIR="$PROJECT_ROOT/logs/tests" TEST_RESULTS_FILE="$TEST_LOG_DIR/test-results-$(date +%Y%m%d-%H%M%S).json" # Ensure test log directory exists mkdir -p "$TEST_LOG_DIR" # Test counters declare -g TESTS_PASSED=0 declare -g TESTS_FAILED=0 declare -g TESTS_SKIPPED=0 # Test runner functions function run_test_suite() { local suite_name="$1" local test_dir="$2" print_header "Running $suite_name Tests" if [[ ! -d "$test_dir" ]]; then print_warning "Test directory $test_dir not found, skipping" return 0 fi for test_file in "$test_dir"/*.sh; do if [[ -f "$test_file" ]]; then run_single_test "$test_file" fi done } function run_single_test() { local test_file="$1" local test_name="$(basename "$test_file" .sh)" print_info "Running test: $test_name" if timeout 300 bash "$test_file"; then print_success "✅ $test_name PASSED" ((TESTS_PASSED++)) else print_error "❌ $test_name FAILED" ((TESTS_FAILED++)) fi } function generate_test_report() { local total_tests=$((TESTS_PASSED + TESTS_FAILED + TESTS_SKIPPED)) print_header "Test Results Summary" print_info "Total Tests: $total_tests" print_success "Passed: $TESTS_PASSED" print_error "Failed: $TESTS_FAILED" print_warning "Skipped: $TESTS_SKIPPED" # Generate JSON report cat > "$TEST_RESULTS_FILE" <