Replace the broken test suite with working GdUnit4 tests
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/
This commit is contained in:
1 parent
87ff3d899b
commit
91adf52cf4
559 files changed
+32474
-2100
No files matched your search
+50
-74
@@ -1,82 +1,58 @@
|
||||
#!/bin/bash
|
||||
#!/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.
|
||||
|
||||
# GdUnit4 Test Runner for MusicPlayer
|
||||
# Usage: ./run_tests.sh [--headless] [--verbose]
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")"
|
||||
|
||||
set -e
|
||||
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
|
||||
}
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd "$SCRIPT_DIR"
|
||||
godot_bin="$(find_godot)"
|
||||
|
||||
# Default flags
|
||||
HEADLESS=false
|
||||
VERBOSE=false
|
||||
|
||||
# Parse arguments
|
||||
for arg in "$@"; do
|
||||
case "$arg" in
|
||||
--headless)
|
||||
HEADLESS=true
|
||||
;;
|
||||
--verbose)
|
||||
VERBOSE=true
|
||||
;;
|
||||
esac
|
||||
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
|
||||
|
||||
# Godot executable (adjust if needed)
|
||||
GODOT_EXEC="godot"
|
||||
# Builds the class cache so class_name types resolve; fast when nothing changed
|
||||
"$godot_bin" --headless --path . --import > /dev/null 2>&1
|
||||
|
||||
# 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
|
||||
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
|
||||
|
||||
# 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 '<failure' test_results.xml || true)
|
||||
if [ "$FAILURES" -gt 0 ]; then
|
||||
echo " - Failures: $FAILURES"
|
||||
fi
|
||||
fi
|
||||
|
||||
exit $EXIT_CODE
|
||||
exit $exit_code
|
||||
Reference in new issue
Block a user