utils/repo_contract/templates/godot.sh
Krzysztof kuhy Rudnicki 6c71d531bb repo contract + coverage_gaps gates, test_changed, dependency bumps
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-10-04 16:27:28 +02:00

26 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
# ============================================================================
# Run only the tests related to files changed vs HEAD (staged, unstaged and
# untracked). Quiet: failures plus a one-line summary. Falls back to the full
# suite when a change cannot be mapped to tests. Generated by repo_contract.
# ============================================================================
set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
CHANGED=()
while IFS= read -r f; do
[[ -n "$f" && -e "$f" ]] && CHANGED+=("$f")
done < <({ git diff --name-only HEAD 2>/dev/null || true; git ls-files --others --exclude-standard; } | sort -u)
# Godot test runners cannot select tests by changed file: any change runs the suite headless.
if [[ ${#CHANGED[@]} -eq 0 ]]; then echo "no changes vs HEAD: nothing to test"; exit 0; fi
if [[ -f addons/gut/gut_cmdln.gd ]]; then
godot --headless -s addons/gut/gut_cmdln.gd -gexit -glog=0
elif [[ -f addons/gdUnit4/bin/GdUnitCmdTool.gd ]]; then
godot --headless -s -d addons/gdUnit4/bin/GdUnitCmdTool.gd -a res://test --ignoreHeadlessMode
else
echo "no GUT or gdUnit4 runner found under addons/" >&2; exit 1
fi