The previous tests never compiled: they used GUT's assert functions, Godot 3 APIs and reassigned autoload functions, so no test ran. - 90 tests: unit tests for the playlist, songs, player scoring, time formatting, search and the server client, plus integration tests that run MainWindow and SyncWindow against a fake server - Keybind tests check that Alt+<number> and Ctrl+Alt+<number> keep following the player rows while players are added and removed - run_tests.sh finds Godot and runs the suite headless (~10 seconds) - CI runs the tests before the build job in gitea-build.yaml; the separate test.yml used a GitHub action that does not exist - GdUnit4 is committed instead of ignored, since the project enables it, and .gitea/ is no longer ignored - Exported builds leave out tests/ and addons/gdUnit4/
59 lines
1.6 KiB
Bash
Executable File
59 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Runs the GdUnit4 test suite headless.
|
|
#
|
|
# Usage: ./run_tests.sh [test path ...]
|
|
# ./run_tests.sh all tests
|
|
# ./run_tests.sh res://tests/unit only unit tests
|
|
# ./run_tests.sh res://tests/unit/test_search.gd a single suite
|
|
#
|
|
# Godot is taken from $GODOT, then `godot` on PATH, then the macOS app bundles.
|
|
|
|
set -euo pipefail
|
|
cd "$(dirname "$0")"
|
|
|
|
find_godot() {
|
|
if [[ -n "${GODOT:-}" ]]; then
|
|
echo "$GODOT"
|
|
return
|
|
fi
|
|
if command -v godot > /dev/null; then
|
|
command -v godot
|
|
return
|
|
fi
|
|
for app in /Applications/Godot.app /Applications/Godot_mono.app; do
|
|
if [[ -x "$app/Contents/MacOS/Godot" ]]; then
|
|
echo "$app/Contents/MacOS/Godot"
|
|
return
|
|
fi
|
|
done
|
|
echo "Godot not found. Install Godot 4.7 or set GODOT=/path/to/godot" >&2
|
|
exit 1
|
|
}
|
|
|
|
godot_bin="$(find_godot)"
|
|
|
|
paths=("$@")
|
|
if [[ ${#paths[@]} -eq 0 ]]; then
|
|
paths=(res://tests/unit res://tests/integration)
|
|
fi
|
|
test_args=()
|
|
for path in "${paths[@]}"; do
|
|
test_args+=(-a "$path")
|
|
done
|
|
|
|
# Builds the class cache so class_name types resolve; fast when nothing changed
|
|
"$godot_bin" --headless --path . --import > /dev/null 2>&1
|
|
|
|
set +e
|
|
"$godot_bin" --headless --path . \
|
|
-s addons/gdUnit4/bin/GdUnitCmdTool.gd --ignoreHeadlessMode "${test_args[@]}"
|
|
exit_code=$?
|
|
set -e
|
|
|
|
# GdUnit4 exits with 101 when tests pass but report warnings (e.g. orphan nodes)
|
|
if [[ $exit_code -eq 101 ]]; then
|
|
echo "Tests passed with warnings, see the report above."
|
|
exit 0
|
|
fi
|
|
exit $exit_code
|