#!/usr/bin/env bash # ═══════════════════════════════════════════════════════════════════════════ # Tactical Shooter — Netcode Bug Bash Test Runner # # Runs all test suites in headless Godot and reports results. # Usage: ./tests/RUN_TESTS.sh # # Requirements: # - Godot 4+ executable in PATH, or set GODOT_BIN env var # ═══════════════════════════════════════════════════════════════════════════ set -euo pipefail # Config SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" GODOT="${GODOT_BIN:-godot}" # ANSI colors RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' CYAN='\033[0;36m' NC='\033[0m' # No Color BOLD='\033[1m' TESTS=( "test_anti_cheat.gd" "test_net_sim.gd" "test_rcon_edge_cases.gd" ) PASS_COUNT=0 FAIL_COUNT=0 SKIP_COUNT=0 RESULTS=() echo "" echo -e "${CYAN}══════════════════════════════════════════════${NC}" echo -e "${CYAN} Tactical Shooter — Netcode Bug Bash Runner${NC}" echo -e "${CYAN}══════════════════════════════════════════════${NC}" echo "" echo " Project: $PROJECT_DIR" echo " Godot: $(which "$GODOT" 2>/dev/null || echo 'NOT FOUND')" echo "" # Check godot is available if ! command -v "$GODOT" &>/dev/null; then echo -e "${RED}ERROR: Godot executable '$GODOT' not found in PATH.${NC}" echo " Set GODOT_BIN env var to the godot binary path, or install Godot." echo "" echo " Example:" echo " export GODOT_BIN=/usr/local/bin/godot" echo " $0" echo "" exit 1 fi # Run each test for test_file in "${TESTS[@]}"; do test_path="$SCRIPT_DIR/$test_file" test_name="${test_file%.gd}" if [ ! -f "$test_path" ]; then echo -e "${YELLOW} [SKIP] $test_name — file not found${NC}" SKIP_COUNT=$((SKIP_COUNT + 1)) RESULTS+=("SKIP|$test_name|file not found") continue fi echo -e "${BOLD}Running: $test_name${NC}" echo " $GODOT --headless --script $test_path" echo "" # Run the test — capture output and exit code set +e output=$("$GODOT" --headless --script "$test_path" 2>&1) exit_code=$? set -e # Print output (indented) echo "$output" | sed 's/^/ /' if [ $exit_code -eq 0 ]; then echo -e "${GREEN} ✓ PASS ($test_name)${NC}" PASS_COUNT=$((PASS_COUNT + 1)) RESULTS+=("PASS|$test_name|") else # Extract failure info from output fail_lines=$(echo "$output" | grep -c "\[FAIL\]" || true) echo -e "${RED} ✗ FAIL ($test_name) — $fail_lines assertion(s) failed${NC}" FAIL_COUNT=$((FAIL_COUNT + 1)) RESULTS+=("FAIL|$test_name|$fail_lines failures") fi echo "" echo "──────────────────────────────────────" echo "" done # Summary echo "" echo -e "${CYAN}══════════════════════════════════════════════${NC}" echo -e "${CYAN} Test Run Complete${NC}" echo -e "${CYAN}══════════════════════════════════════════════${NC}" echo "" for result in "${RESULTS[@]}"; do IFS='|' read -r status name info <<< "$result" case "$status" in PASS) echo -e " ${GREEN}✓${NC} $name" ;; FAIL) echo -e " ${RED}✗${NC} $name — $info" ;; SKIP) echo -e " ${YELLOW}—${NC} $name ($info)" ;; esac done echo "" echo -e " ${BOLD}${GREEN}$PASS_COUNT passed${NC}, ${BOLD}${RED}$FAIL_COUNT failed${NC}, ${YELLOW}$SKIP_COUNT skipped${NC}" echo "" if [ $FAIL_COUNT -gt 0 ]; then exit 1 fi exit 0