chore: install gut quality suite
This commit is contained in:
+52
-6
@@ -163,6 +163,40 @@ if (-not $GODOT) {
|
||||
exit 1
|
||||
}
|
||||
|
||||
# -- 0. Godot import bootstrap ------------------------------------------------
|
||||
$importResult = "PASS"
|
||||
Set-Content -Path "$LOG/godot-import.log" -Value "" -Encoding utf8
|
||||
$classCache = Join-Path $ROOT ".godot/global_script_class_cache.cfg"
|
||||
$hasProjectClasses = (Test-Path $classCache) -and
|
||||
(Select-String -Path $classCache -SimpleMatch '"class": &"SimNPC"' -Quiet)
|
||||
$hasGutClasses = (Test-Path $classCache) -and
|
||||
(Select-String -Path $classCache -SimpleMatch '"class": &"GutTest"' -Quiet)
|
||||
$needsImport = (-not $hasProjectClasses) -or
|
||||
((Test-Path "addons/gut/gut_cmdln.gd") -and (-not $hasGutClasses))
|
||||
if ($needsImport) {
|
||||
$importArgs = "--headless --path `"$ROOT`" --import"
|
||||
$importOutput, $importExit = Invoke-GodotWithTimeout -ArgumentString $importArgs
|
||||
$importOutput | Add-Content -Path "$LOG/godot-import.log" -Encoding utf8
|
||||
if ($importExit -eq $null -or $importExit -ne 0) {
|
||||
$importResult = "FAIL"
|
||||
}
|
||||
}
|
||||
$hasProjectClasses = (Test-Path $classCache) -and
|
||||
(Select-String -Path $classCache -SimpleMatch '"class": &"SimNPC"' -Quiet)
|
||||
$hasGutClasses = (Test-Path $classCache) -and
|
||||
(Select-String -Path $classCache -SimpleMatch '"class": &"GutTest"' -Quiet)
|
||||
if (-not $hasProjectClasses -or ((Test-Path "addons/gut/gut_cmdln.gd") -and (-not $hasGutClasses))) {
|
||||
$importResult = "FAIL"
|
||||
}
|
||||
$importLoadError = Select-String -Path "$LOG/godot-import.log" -Pattern 'SCRIPT ERROR:|Parse Error:|Failed to load script' -Quiet
|
||||
if ($importLoadError) {
|
||||
$importResult = "FAIL"
|
||||
}
|
||||
if ($importResult -eq "FAIL") {
|
||||
$ERRORS += "godot-import: failed to build the global class cache"
|
||||
$FIXES += "Fix Godot import errors before running headless checks"
|
||||
}
|
||||
|
||||
# -- 1. gdformat --------------------------------------------------------------
|
||||
$fmtAvail = Test-GdFormat
|
||||
$fmtResult = "PASS"
|
||||
@@ -285,13 +319,17 @@ if ($scenarioResult -eq "FAIL") {
|
||||
$FIXES += "Fix failing project scenario tests"
|
||||
}
|
||||
|
||||
# -- 5. GUT (optional) --------------------------------------------------------
|
||||
$gutResult = "SKIPPED"
|
||||
# -- 5. GUT -------------------------------------------------------------------
|
||||
$gutResult = "PASS"
|
||||
Set-Content -Path "$LOG/gut.log" -Value "" -Encoding utf8
|
||||
if (Test-Path "addons/gut/gut_cmdln.gd") {
|
||||
$gutArgs = "--headless --path `"$ROOT`" -s addons/gut/gut_cmdln.gd --quit"
|
||||
if (-not (Test-Path "addons/gut/gut_cmdln.gd")) {
|
||||
$gutResult = "FAIL"
|
||||
$ERRORS += "gut: pinned addon is missing"
|
||||
$FIXES += "Restore addons/gut from pinned GUT v9.7.1"
|
||||
} else {
|
||||
$gutArgs = "--headless --path `"$ROOT`" -s addons/gut/gut_cmdln.gd -gexit -gdisable_colors"
|
||||
$gutOutput, $gutExit = Invoke-GodotWithTimeout -ArgumentString $gutArgs
|
||||
$gutOutput | Out-File -FilePath "$LOG/gut.log" -Encoding utf8
|
||||
$gutOutput | Add-Content -Path "$LOG/gut.log" -Encoding utf8
|
||||
if ($gutExit -eq $null) {
|
||||
$gutResult = "FAIL"
|
||||
Add-Content -Path "$LOG/gut.log" -Value "[timed out after 30s]" -Encoding utf8
|
||||
@@ -306,16 +344,23 @@ if (Test-Path "addons/gut/gut_cmdln.gd") {
|
||||
}
|
||||
$FIXES += "Fix failing GUT tests"
|
||||
}
|
||||
$gutLoadError = Select-String -Path "$LOG/gut.log" -Pattern 'Some GUT class_names have not been imported|SCRIPT ERROR:|Parse Error:|Failed to load script' -Quiet
|
||||
if ($gutLoadError) {
|
||||
$gutResult = "FAIL"
|
||||
$ERRORS += "gut: addon or unit tests failed to load"
|
||||
$FIXES += "Run Godot 4.7 headless import and fix GUT load errors"
|
||||
}
|
||||
}
|
||||
|
||||
# -- summary ------------------------------------------------------------------
|
||||
if ($fmtResult -eq 'FAIL' -or $lintResult -eq 'FAIL' -or $godotResult -eq 'FAIL' -or $scenarioResult -eq 'FAIL' -or $gutResult -eq 'FAIL') {
|
||||
if ($importResult -eq 'FAIL' -or $fmtResult -eq 'FAIL' -or $lintResult -eq 'FAIL' -or $godotResult -eq 'FAIL' -or $scenarioResult -eq 'FAIL' -or $gutResult -eq 'FAIL') {
|
||||
$OVERALL = $true
|
||||
}
|
||||
|
||||
Write-Host ""
|
||||
if ($OVERALL) { Write-Host "QUALITY RESULT: FAIL" } else { Write-Host "QUALITY RESULT: PASS" }
|
||||
Write-Host ""
|
||||
Write-Host " godot-import $importResult"
|
||||
Write-Host " gdformat $fmtResult"
|
||||
Write-Host " gdlint $lintResult"
|
||||
Write-Host " godot-check $godotResult"
|
||||
@@ -352,6 +397,7 @@ if ($OVERALL) { $resultText = "FAIL" } else { $resultText = "PASS" }
|
||||
$summary = @"
|
||||
QUALITY RESULT: $resultText
|
||||
|
||||
godot-import $importResult
|
||||
gdformat $fmtResult
|
||||
gdlint $lintResult
|
||||
godot-check $godotResult
|
||||
|
||||
+62
-8
@@ -95,6 +95,41 @@ if [[ -z "$GODOT" ]]; then
|
||||
fi
|
||||
GODOT_ENV=(env "HOME=$GODOT_PROFILE" "APPDATA=$GODOT_PROFILE" "LOCALAPPDATA=$GODOT_PROFILE")
|
||||
|
||||
# -- 0. Godot import bootstrap ------------------------------------------------
|
||||
import_result="PASS"
|
||||
: > "$LOG/godot-import.log"
|
||||
class_cache="$ROOT/.godot/global_script_class_cache.cfg"
|
||||
needs_import=false
|
||||
[[ ! -f "$class_cache" ]] && needs_import=true
|
||||
if [[ -f "addons/gut/gut_cmdln.gd" ]] && ! grep -q '"class": &"GutTest"' "$class_cache" 2>/dev/null; then
|
||||
needs_import=true
|
||||
fi
|
||||
if $needs_import; then
|
||||
if need_timeout; then
|
||||
timeout 60 "${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" --import >> "$LOG/godot-import.log" 2>&1
|
||||
import_exit=$?
|
||||
else
|
||||
"${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" --import >> "$LOG/godot-import.log" 2>&1
|
||||
import_exit=$?
|
||||
fi
|
||||
if [[ $import_exit -ne 0 ]]; then
|
||||
import_result="FAIL"
|
||||
fi
|
||||
fi
|
||||
if [[ ! -f "$class_cache" ]] || ! grep -q '"class": &"SimNPC"' "$class_cache"; then
|
||||
import_result="FAIL"
|
||||
fi
|
||||
if [[ -f "addons/gut/gut_cmdln.gd" ]] && ! grep -q '"class": &"GutTest"' "$class_cache" 2>/dev/null; then
|
||||
import_result="FAIL"
|
||||
fi
|
||||
if grep -qE "SCRIPT ERROR:|Parse Error:|Failed to load script" "$LOG/godot-import.log"; then
|
||||
import_result="FAIL"
|
||||
fi
|
||||
if [[ "$import_result" == "FAIL" ]]; then
|
||||
ERRORS+=("godot-import: failed to build the global class cache")
|
||||
FIXES+=("Fix Godot import errors before running headless checks")
|
||||
fi
|
||||
|
||||
# -- 1. gdformat --------------------------------------------------------------
|
||||
fmt_tool=$(find_gdformat) || true
|
||||
fmt_result="PASS"
|
||||
@@ -231,23 +266,40 @@ if [[ "$scenario_result" == "FAIL" ]]; then
|
||||
FIXES+=("Fix failing project scenario tests")
|
||||
fi
|
||||
|
||||
# -- 5. GUT (optional) --------------------------------------------------------
|
||||
gut_result="SKIPPED"
|
||||
# -- 5. GUT -------------------------------------------------------------------
|
||||
gut_result="PASS"
|
||||
: > "$LOG/gut.log"
|
||||
if [[ -f "addons/gut/gut_cmdln.gd" ]]; then
|
||||
if "${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT" -s addons/gut/gut_cmdln.gd >> "$LOG/gut.log" 2>&1; then
|
||||
if [[ ! -f "addons/gut/gut_cmdln.gd" ]]; then
|
||||
gut_result="FAIL"
|
||||
ERRORS+=("gut: pinned addon is missing")
|
||||
FIXES+=("Restore addons/gut from pinned GUT v9.7.1")
|
||||
else
|
||||
gut_command=(
|
||||
"${GODOT_ENV[@]}" "$GODOT" --headless --path "$ROOT"
|
||||
-s addons/gut/gut_cmdln.gd -gexit -gdisable_colors
|
||||
)
|
||||
if need_timeout; then
|
||||
timeout 30 "${gut_command[@]}" >> "$LOG/gut.log" 2>&1
|
||||
gut_exit=$?
|
||||
else
|
||||
"${gut_command[@]}" >> "$LOG/gut.log" 2>&1
|
||||
gut_exit=$?
|
||||
fi
|
||||
if [[ $gut_exit -eq 0 ]]; then
|
||||
gut_result="PASS"
|
||||
else
|
||||
gut_result="FAIL"
|
||||
grep -iE "fail|error|assert" "$LOG/gut.log" 2>/dev/null | head -20 | while IFS= read -r errline; do
|
||||
ERRORS+=("gut: $errline")
|
||||
done
|
||||
FIXES+=("Fix failing GUT tests")
|
||||
fi
|
||||
if grep -qE "Some GUT class_names have not been imported|SCRIPT ERROR:|Parse Error:|Failed to load script" "$LOG/gut.log"; then
|
||||
gut_result="FAIL"
|
||||
ERRORS+=("gut: addon or unit tests failed to load")
|
||||
FIXES+=("Run Godot 4.7 headless import and fix GUT load errors")
|
||||
fi
|
||||
fi
|
||||
|
||||
# -- summary ------------------------------------------------------------------
|
||||
if [[ "$fmt_result" == "FAIL" || "$lint_result" == "FAIL" || "$godot_result" == "FAIL" || "$scenario_result" == "FAIL" || "$gut_result" == "FAIL" ]]; then
|
||||
if [[ "$import_result" == "FAIL" || "$fmt_result" == "FAIL" || "$lint_result" == "FAIL" || "$godot_result" == "FAIL" || "$scenario_result" == "FAIL" || "$gut_result" == "FAIL" ]]; then
|
||||
OVERALL=true
|
||||
fi
|
||||
|
||||
@@ -258,6 +310,7 @@ else
|
||||
echo "QUALITY RESULT: PASS"
|
||||
fi
|
||||
echo ""
|
||||
echo " godot-import $import_result"
|
||||
echo " gdformat $fmt_result"
|
||||
echo " gdlint $lint_result"
|
||||
echo " godot-check $godot_result"
|
||||
@@ -294,6 +347,7 @@ echo ""
|
||||
{
|
||||
echo "QUALITY RESULT: $($OVERALL && echo FAIL || echo PASS)"
|
||||
echo ""
|
||||
echo " godot-import $import_result"
|
||||
echo " gdformat $fmt_result"
|
||||
echo " gdlint $lint_result"
|
||||
echo " godot-check $godot_result"
|
||||
|
||||
Reference in New Issue
Block a user