mp fix
This commit is contained in:
+62
-24
@@ -1,41 +1,69 @@
|
||||
# Runs the headless two-instance multiplayer test (test/multiPlayerTest.tscn).
|
||||
# Runs the two-instance multiplayer test and ALWAYS produces a GIF of the run.
|
||||
#
|
||||
# powershell -File test\run_mp_test.ps1
|
||||
#
|
||||
# Starts a server instance and a client instance of the game with --xr-mode off
|
||||
# (SteamVR's OpenXR runtime crashes a headless process), lets test/mp_test_driver.gd
|
||||
# drive the scripted plate/dirt-station sequence, then prints both logs.
|
||||
# Starts a server instance and a client instance on test/multiPlayerTest.tscn,
|
||||
# lets test/mp_test_driver.gd drive the scripted kitchen sequence, then writes:
|
||||
# logs\mptest_report.txt - every check, pass/fail, plus failure details
|
||||
# logs\mptest_run.gif - both peers side by side, one frame per step
|
||||
# logs\mptest_{server,client}.log - full step logs
|
||||
# Exits non-zero if any check failed.
|
||||
#
|
||||
# The windows are visible because frame capture needs a real framebuffer: a
|
||||
# headless Godot renders nothing, so there would be no GIF. Use -Headless when
|
||||
# you only want the pass/fail result (faster, but no GIF).
|
||||
|
||||
param(
|
||||
[string]$Godot = "C:\Users\Aqua Aurora\Desktop\Godot_v4.7-stable_win64.exe",
|
||||
[int]$TimeoutSec = 120
|
||||
[int]$TimeoutSec = 400,
|
||||
# Seconds to pause between steps, and to hold the final state on screen.
|
||||
[double]$Pause = 0.4,
|
||||
[double]$Hold = 3,
|
||||
# Passed through to make_gif.ps1.
|
||||
[int]$HalfWidth = 900,
|
||||
[double]$SecondsPerStep = 1.2,
|
||||
# Skip the windows entirely. No frames are captured, so no GIF is produced.
|
||||
[switch]$Headless
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$proj = Split-Path -Parent $PSScriptRoot
|
||||
$scene = "res://test/multiPlayerTest.tscn"
|
||||
# The two peers deliberately load DIFFERENT scenes, mirroring the real game:
|
||||
# the host opens whatever world it is running, the client opens the bare
|
||||
# multiplayer scene and must receive the entire layout over the network. That is
|
||||
# also exactly what a client joining mid-session goes through.
|
||||
$serverScene = "res://test/multiPlayerTest.tscn"
|
||||
$clientScene = "res://Scenes/multiPlayer.tscn"
|
||||
$serverLog = Join-Path $proj "logs/mptest_server.log"
|
||||
$clientLog = Join-Path $proj "logs/mptest_client.log"
|
||||
$report = Join-Path $proj "logs/mptest_report.txt"
|
||||
$gif = Join-Path $proj "logs/mptest_run.gif"
|
||||
|
||||
foreach ($f in @($serverLog, $clientLog)) { if (Test-Path $f) { Remove-Item $f -Force } }
|
||||
foreach ($f in @($serverLog, $clientLog, $report, $gif)) { if (Test-Path $f) { Remove-Item $f -Force } }
|
||||
|
||||
function Start-Instance($extraArgs) {
|
||||
# Single argument string with the project path quoted: Start-Process does
|
||||
# not quote array elements, so the space in the path would split it.
|
||||
$a = "--headless --xr-mode off --path `"$proj`" $scene -- $($extraArgs -join ' ')"
|
||||
$p = Start-Process -FilePath $Godot -ArgumentList $a -PassThru -NoNewWindow
|
||||
# Touching .Handle caches it, which is what makes .ExitCode readable later;
|
||||
# without this it comes back empty even after the process has exited.
|
||||
. (Join-Path $PSScriptRoot "mp_window_layout.ps1")
|
||||
|
||||
function Start-Instance($extraArgs, $sceneFor) {
|
||||
# --xr-mode off keeps it on the desktop (SteamVR's OpenXR runtime otherwise
|
||||
# takes over, and two instances can't share a headset anyway).
|
||||
$a = "--xr-mode off"
|
||||
if ($Headless) { $a = "--headless " + $a }
|
||||
$a += " --resolution 900x600 --path `"$proj`" $sceneFor -- $($extraArgs -join ' ') --mptest"
|
||||
if (-not $Headless) { $a += " --mptest-frames" }
|
||||
$a += " --mptest-pause $Pause --mptest-hold $Hold"
|
||||
$p = Start-Process -FilePath $Godot -ArgumentList $a -PassThru -NoNewWindow:$Headless
|
||||
# Touching .Handle caches it, which is what makes .ExitCode readable later.
|
||||
$null = $p.Handle
|
||||
return $p
|
||||
}
|
||||
|
||||
Write-Host "Starting server..."
|
||||
$server = Start-Instance @("--server", "--mptest")
|
||||
Start-Sleep -Seconds 4
|
||||
Write-Host "Starting client..."
|
||||
$client = Start-Instance @("--join", "127.0.0.1", "--mptest")
|
||||
Write-Host "Starting SERVER..."
|
||||
$server = Start-Instance @("--server") $serverScene
|
||||
if (-not $Headless) { $w = Move-GameWindow $server 20 60 }
|
||||
Start-Sleep -Seconds 5
|
||||
Write-Host "Starting CLIENT..."
|
||||
$client = Start-Instance @("--join", "127.0.0.1") $clientScene
|
||||
if (-not $Headless) { $null = Move-GameWindow $client (20 + $w + 12) 60 }
|
||||
|
||||
$deadline = (Get-Date).AddSeconds($TimeoutSec)
|
||||
while ((Get-Date) -lt $deadline -and -not $server.HasExited) { Start-Sleep -Milliseconds 500 }
|
||||
@@ -45,16 +73,26 @@ foreach ($p in @($server, $client)) {
|
||||
}
|
||||
Start-Sleep -Milliseconds 500
|
||||
|
||||
foreach ($pair in @(@("SERVER", $serverLog), @("CLIENT", $clientLog))) {
|
||||
if (-not $Headless) {
|
||||
Write-Host ""
|
||||
Write-Host "======================== $($pair[0]) ========================"
|
||||
if (Test-Path $pair[1]) { Get-Content $pair[1] -Encoding UTF8 } else { Write-Host "(no log written)" }
|
||||
Write-Host "======================== GIF ========================"
|
||||
& powershell -ExecutionPolicy Bypass -File (Join-Path $PSScriptRoot "make_gif.ps1") `
|
||||
-HalfWidth $HalfWidth -SecondsPerStep $SecondsPerStep
|
||||
} else {
|
||||
Write-Host ""
|
||||
Write-Host "(headless run: no frames captured, so no GIF - drop -Headless to get one)"
|
||||
}
|
||||
|
||||
# ExitCode is only populated on the process object after a WaitForExit() call,
|
||||
# even when HasExited is already true - without this it reads back empty.
|
||||
Write-Host ""
|
||||
Write-Host "======================== REPORT ========================"
|
||||
if (Test-Path $report) { Get-Content $report -Encoding UTF8 } else { Write-Host "(no report written - the run did not finish)" }
|
||||
|
||||
$server.WaitForExit(2000) | Out-Null
|
||||
$code = if ($server.HasExited) { $server.ExitCode } else { 1 }
|
||||
Write-Host ""
|
||||
Write-Host "report: $report"
|
||||
if (-not $Headless -and (Test-Path $gif)) { Write-Host "gif: $gif" }
|
||||
Write-Host "logs: $serverLog"
|
||||
Write-Host " $clientLog"
|
||||
Write-Host "server exit code: $code"
|
||||
exit $code
|
||||
|
||||
Reference in New Issue
Block a user