|
| 1 | +# Define Godot executable (uses environment variable if set, else defaults to 'godot') |
| 2 | +$GODOT = if ($env:GODOT) { $env:GODOT } else { 'godot' } |
| 3 | + |
| 4 | +$END_STRING = "==== TESTS FINISHED ====" |
| 5 | +$FAILURE_STRING = "******** FAILED ********" |
| 6 | +$HAS_FAILURE = 0 |
| 7 | + |
| 8 | +# Function to filter spam from output |
| 9 | +function Filter-Output { |
| 10 | + param([string[]]$Lines) |
| 11 | + $Lines | ForEach-Object { $_.TrimEnd() } | Where-Object { |
| 12 | + $_ -notmatch "Narrowing conversion" -and |
| 13 | + $_ -notmatch "at:\s+GDScript::reload" -and |
| 14 | + $_ -notmatch "\[\s*\d+%\s*\]" -and |
| 15 | + $_ -notmatch "first_scan_filesystem" -and |
| 16 | + $_ -notmatch "loading_editor_layout" |
| 17 | + } |
| 18 | +} |
| 19 | + |
| 20 | +# Run Godot and capture output and exit code |
| 21 | +try { |
| 22 | + $OUTPUT = & $GODOT --path project --debug --headless --quit 2>&1 |
| 23 | + $ERRCODE = $LASTEXITCODE |
| 24 | +} |
| 25 | +catch { |
| 26 | + $OUTPUT = $_.Exception.Message |
| 27 | + $ERRCODE = 1 |
| 28 | +} |
| 29 | + |
| 30 | +# Output the results |
| 31 | +Write-Output $OUTPUT |
| 32 | +Write-Output "" |
| 33 | + |
| 34 | +# Check if tests completed |
| 35 | +if (-not ($OUTPUT -match [regex]::Escape($END_STRING))) { |
| 36 | + $HAS_FAILURE += 1 |
| 37 | +} |
| 38 | + |
| 39 | +# Check for test failures |
| 40 | +if ($OUTPUT -match [regex]::Escape($FAILURE_STRING)) { |
| 41 | + $HAS_FAILURE += 1 |
| 42 | +} |
| 43 | + |
| 44 | +# Lock file path (relative to project dir) |
| 45 | +$LOCK_PATH = "project/test_reload_lock" |
| 46 | + |
| 47 | +# Delete lock file before reload test if it exists |
| 48 | +Remove-Item -Path $LOCK_PATH -Force -ErrorAction SilentlyContinue |
| 49 | + |
| 50 | +# Run Godot and capture output and exit code |
| 51 | +try { |
| 52 | + $OUTPUT = & $GODOT -e --path project --scene reload.tscn --headless --debug test_reload 2>&1 |
| 53 | + $ERRCODE = $LASTEXITCODE |
| 54 | +} |
| 55 | +catch { |
| 56 | + $OUTPUT = $_.Exception.Message |
| 57 | + $ERRCODE = 1 |
| 58 | +} |
| 59 | + |
| 60 | +# Filter and output the results |
| 61 | +$FilteredOutput = Filter-Output -Lines ($OUTPUT -split "`n") |
| 62 | +Write-Output ($FilteredOutput -join "`n") |
| 63 | +Write-Output "" |
| 64 | + |
| 65 | +# Check for test failures |
| 66 | +if ($OUTPUT -match [regex]::Escape($FAILURE_STRING)) { |
| 67 | + $HAS_FAILURE += 1 |
| 68 | +} |
| 69 | + |
| 70 | +# Lock file path (relative to project dir) |
| 71 | +$LOCK_PATH = "project/test_reload_lock" |
| 72 | + |
| 73 | +# Delete lock file before reload test if it exists |
| 74 | +Remove-Item -Path $LOCK_PATH -Force -ErrorAction SilentlyContinue |
| 75 | + |
| 76 | +if ($HAS_FAILURE -gt 0 ){ |
| 77 | + Write-Output "ERROR: Tests failed to complete" |
| 78 | + exit 1 |
| 79 | +} |
| 80 | + |
| 81 | +# Success! |
| 82 | +exit 0 |
0 commit comments