#!/bin/bash
# Sentinel Test Runner
# Executes gdUnit4 tests in headless mode
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="${GODOT_PROJECT_ROOT:-$(dirname "$SCRIPT_DIR")/game}"
if [ ! -d "$PROJECT_ROOT" ]; then
echo "β Project root not found: $PROJECT_ROOT"
echo "Set GODOT_PROJECT_ROOT environment variable or ensure ../game exists"
exit 1
fi
if [ ! -f "$PROJECT_ROOT/project.godot" ]; then
echo "β Not a Godot project: $PROJECT_ROOT"
exit 1
fi
# Check if gdUnit4 is installed
GDUNIT_PATH="$PROJECT_ROOT/addons/gdUnit4"
if [ ! -d "$GDUNIT_PATH" ]; then
echo "β gdUnit4 not found in: $GDUNIT_PATH"
echo "Install gdUnit4 from: https://github.com/MikeSchulze/gdUnit4"
exit 1
fi
echo "π§ͺ Running Godot tests..."
echo "π Project: $PROJECT_ROOT"
cd "$PROJECT_ROOT"
# Run gdUnit4 tests in headless mode
# --verbose for detailed output
# -gexit to quit after tests
# -s to run specific script (gdUnit4 runner)
godot --headless -s res://addons/gdUnit4/bin/gdUnit4.gd -gexit --verbose 2>&1
TEST_EXIT_CODE=$?
if [ $TEST_EXIT_CODE -eq 0 ]; then
echo "β All tests passed!"
else
echo "β Tests failed (exit code: $TEST_EXIT_CODE)"
fi
exit $TEST_EXIT_CODE