#!/bin/bash # GdUnit4 Test Runner for MusicPlayer # Usage: ./run_tests.sh [--headless] [--verbose] set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$SCRIPT_DIR" # Default flags HEADLESS=false VERBOSE=false # Parse arguments for arg in "$@"; do case "$arg" in --headless) HEADLESS=true ;; --verbose) VERBOSE=true ;; esac done # Godot executable (adjust if needed) GODOT_EXEC="godot" # Check if Godot is available if ! command -v "$GODOT_EXEC" &> /dev/null; then echo "Error: Godot executable not found at: $GODOT_EXEC" echo "Please ensure Godot 4.7 is installed and in your PATH" exit 1 fi # Build arguments GODOT_ARGS=( "--path" "." "-s" "addons/gdUnit4/test.gd" "--gdunit.cli" ) if [ "$HEADLESS" = true ]; then GODOT_ARGS+=("--headless") fi if [ "$VERBOSE" = true ]; then GODOT_ARGS+=("--verbose") fi echo "Running tests with Godot..." echo "Command: $GODOT_EXEC ${GODOT_ARGS[*]}" echo "" # Run tests "$GODOT_EXEC" "${GODOT_ARGS[@]}" EXIT_CODE=$? # Check results echo "" if [ $EXIT_CODE -eq 0 ]; then echo "✓ All tests passed!" else echo "✗ Tests failed with exit code: $EXIT_CODE" fi # Check for test results files if [ -f "test_results.xml" ]; then echo "" echo "Test results:" echo " - JUnit XML: test_results.xml" echo " - HTML: test_results.html" # Count failures FAILURES=$(grep -c '