Snapshot for release 2026.10.22.2 (internal 466f796)

This commit is contained in:
Tom Bohar 2026-10-22 16:42:32 -04:00
commit 2be3668232
12 changed files with 666 additions and 27 deletions

155
scripts/Run-AllTests.ps1 Normal file
View file

@ -0,0 +1,155 @@
#Requires -Version 7
<#
.SYNOPSIS
Builds and runs every offline test program in RynthCore, RynthSuite and RynthServers. Exit 0 only
when every one passes.
.DESCRIPTION
The test programs are console apps: RynthCore tools\*Tests, RynthSuite and RynthServers Tools\*Tests,
each run as `dotnet run -c Release` from its own folder (exit 0 = pass, anything else = fail), and the
loader's C tests (a Run-Tests.ps1 beside test.c, built with MSVC). None needs a game client, a server
or the network, and none writes to %APPDATA% or C:\Games (each project's header says what it reads).
Publish-Update.ps1 runs this before it builds a release and refuses to publish when a test fails
(2026-10-22: tests only ran when someone remembered to; a release went out with Missile Crafting
broken while the tests that existed passed).
Every folder whose name contains "Test" is run unless $Skip below names it with a reason; skipped ones
are listed in the summary, never dropped silently. Each program's output goes to
<LogDir>\<repo>.<name>.log, and the summary (also <LogDir>\summary.txt) shows each failure's last lines.
.EXAMPLE
.\scripts\Run-AllTests.ps1 -RynthSuiteRoot C:\Projects\rel1002\RynthSuite
.EXAMPLE
.\scripts\Run-AllTests.ps1 -Only RynthCore.RynthAiHostTests, ChatFilterTests
#>
param(
[string]$RynthCoreRoot = "", # defaults to this checkout
[string]$RynthSuiteRoot = "", # defaults to ..\RynthSuite beside RynthCore
[string]$RynthServersRoot = "", # defaults to ..\RynthServers beside RynthSuite
[string[]]$Only = @(), # folder names (or repo.name) to run; empty = all
[string]$LogDir = "", # defaults to %TEMP%\rynth-tests\<time>
[int]$TimeoutMinutes = 10 # per program, build and run each
)
$ErrorActionPreference = "Stop"
if (-not $RynthCoreRoot) { $RynthCoreRoot = Split-Path $PSScriptRoot -Parent }
if (-not $RynthSuiteRoot) { $RynthSuiteRoot = Join-Path (Split-Path $RynthCoreRoot -Parent) "RynthSuite" }
if (-not $RynthServersRoot) { $RynthServersRoot = Join-Path (Split-Path $RynthSuiteRoot -Parent) "RynthServers" }
if (-not $LogDir) { $LogDir = Join-Path $env:TEMP ("rynth-tests\" + (Get-Date -Format "yyyyMMdd-HHmmss")) }
New-Item -ItemType Directory -Force $LogDir | Out-Null
$env:DOTNET_NOLOGO = "1"
$env:DOTNET_CLI_TELEMETRY_OPTOUT = "1"
# Folders with "Test" in the name that are not tests, and tests that can't run here. Each needs a reason.
$Skip = @{
"HookResolver.SmokeTest" = "prints the hooks it resolves in acclient.exe and checks nothing (always exits 0)"
"TestClient" = "builds a stand-in acclient.exe for the reload scripts; not a test"
}
$repos = @(
@{ Name = "RynthCore"; Root = $RynthCoreRoot; Tools = "tools" },
@{ Name = "RynthSuite"; Root = $RynthSuiteRoot; Tools = "Tools" },
@{ Name = "RynthServers"; Root = $RynthServersRoot; Tools = "Tools" }
)
$tests = [System.Collections.Generic.List[object]]::new()
$skipped = [System.Collections.Generic.List[object]]::new()
foreach ($r in $repos) {
$dir = Join-Path $r.Root $r.Tools
if (-not (Test-Path $dir)) { throw "No $($r.Tools) folder in $($r.Name) at $($r.Root)" }
foreach ($d in Get-ChildItem $dir -Directory | Where-Object Name -like "*Test*" | Sort-Object Name) {
$id = "$($r.Name).$($d.Name)"
if ($Only.Count -gt 0 -and -not ($Only -contains $d.Name -or $Only -contains $id)) { continue }
if ($Skip.ContainsKey($d.Name)) { $skipped.Add([pscustomobject]@{ Id = $id; Why = $Skip[$d.Name] }); continue }
$proj = Get-ChildItem $d.FullName -Filter *.csproj | Select-Object -First 1
$ps = Join-Path $d.FullName "Run-Tests.ps1"
if ($proj) { $tests.Add([pscustomobject]@{ Id = $id; Dir = $d.FullName; Kind = "dotnet"; Path = $proj.FullName }) }
elseif (Test-Path $ps) { $tests.Add([pscustomobject]@{ Id = $id; Dir = $d.FullName; Kind = "script"; Path = $ps }) }
elseif (-not (Get-ChildItem $d.FullName -Force | Where-Object Name -notin "bin", "obj")) {
# Git doesn't remove ignored build output, so a moved or deleted project leaves its bin\obj behind.
$skipped.Add([pscustomobject]@{ Id = $id; Why = "only build output left (bin, obj): the project moved or was deleted" })
}
else { $tests.Add([pscustomobject]@{ Id = $id; Dir = $d.FullName; Kind = "none"; Path = "" }) }
}
}
if ($Only.Count -gt 0 -and $tests.Count -eq 0 -and $skipped.Count -eq 0) { throw "-Only matched no test folder: $($Only -join ', ')" }
# Runs one program with its output captured; returns @{ Code; TimedOut; Output }.
function Invoke-Captured([string]$file, [string[]]$argList, [string]$cwd) {
$psi = [System.Diagnostics.ProcessStartInfo]::new($file)
foreach ($a in $argList) { $psi.ArgumentList.Add($a) }
$psi.WorkingDirectory = $cwd
$psi.UseShellExecute = $false
$psi.RedirectStandardOutput = $true
$psi.RedirectStandardError = $true
$psi.RedirectStandardInput = $true # a program that waits for a key gets end-of-input, not a hang
$p = [System.Diagnostics.Process]::Start($psi)
$p.StandardInput.Close()
$out = $p.StandardOutput.ReadToEndAsync()
$err = $p.StandardError.ReadToEndAsync()
$timedOut = -not $p.WaitForExit($TimeoutMinutes * 60 * 1000)
if ($timedOut) { try { $p.Kill($true) } catch { } ; $p.WaitForExit() }
$p.WaitForExit() # drains the readers
$text = $out.Result
if ($err.Result) { $text += "`n--- stderr ---`n" + $err.Result }
return @{ Code = $p.ExitCode; TimedOut = $timedOut; Output = $text }
}
$results = [System.Collections.Generic.List[object]]::new()
$i = 0
foreach ($t in $tests) {
$i++
$log = Join-Path $LogDir "$($t.Id).log"
$sw = [System.Diagnostics.Stopwatch]::StartNew()
$status = "PASS"; $text = ""
Write-Host ("[{0,2}/{1}] {2} ... " -f $i, $tests.Count, $t.Id) -NoNewline
switch ($t.Kind) {
"none" { $status = "FAIL"; $text = "no .csproj and no Run-Tests.ps1 in $($t.Dir) (add one, or list the folder in `$Skip with a reason)" }
"script" {
$r = Invoke-Captured "pwsh" @("-NoProfile", "-NonInteractive", "-File", $t.Path) $t.Dir
$text = $r.Output
if ($r.TimedOut) { $status = "TIMEOUT" } elseif ($r.Code -ne 0) { $status = "FAIL" }
}
"dotnet" {
# The same as `dotnet run -c Release` from the project's folder, without dotnet run's
# ~10 s of project evaluation per program: build, then start what was built. -t:Build is
# needed: -getProperty alone only evaluates the project and builds nothing (an old build
# would then be tested).
$b = Invoke-Captured "dotnet" @("build", $t.Path, "-c", "Release", "-nologo", "-t:Build", "-getProperty:TargetPath") $t.Dir
$text = "=== build ===`n" + $b.Output
$dll = ($b.Output -split "`r?`n" | Where-Object { $_ -match '\.dll\s*$' } | Select-Object -Last 1)
if ($b.TimedOut) { $status = "TIMEOUT (build)" }
elseif ($b.Code -ne 0) { $status = "BUILD FAILED" }
elseif (-not $dll -or -not (Test-Path $dll.Trim())) { $status = "BUILD FAILED"; $text += "`n(no built program found)" }
else {
$dll = $dll.Trim()
$exe = [IO.Path]::ChangeExtension($dll, ".exe")
$r = if (Test-Path $exe) { Invoke-Captured $exe @() $t.Dir } else { Invoke-Captured "dotnet" @($dll) $t.Dir }
$text += "`n=== run ===`n" + $r.Output
if ($r.TimedOut) { $status = "TIMEOUT" } elseif ($r.Code -ne 0) { $status = "FAIL (exit $($r.Code))" }
}
}
}
$sw.Stop()
Set-Content $log $text
$color = if ($status -eq "PASS") { "Green" } else { "Red" }
Write-Host ("{0} ({1:0}s)" -f $status, $sw.Elapsed.TotalSeconds) -ForegroundColor $color
$results.Add([pscustomobject]@{ Id = $t.Id; Status = $status; Seconds = [math]::Round($sw.Elapsed.TotalSeconds); Log = $log })
}
$failed = @($results | Where-Object Status -ne "PASS")
$summary = [System.Collections.Generic.List[string]]::new()
$summary.Add("RynthCore $(git -C $RynthCoreRoot rev-parse --short HEAD) ($RynthCoreRoot), RynthSuite $(git -C $RynthSuiteRoot rev-parse --short HEAD) ($RynthSuiteRoot), RynthServers $(git -C $RynthServersRoot rev-parse --short HEAD) ($RynthServersRoot)")
$summary.Add("$($results.Count - $failed.Count) of $($results.Count) test programs passed, $($failed.Count) failed, $($skipped.Count) skipped. Logs: $LogDir")
foreach ($s in $skipped) { $summary.Add(" skipped $($s.Id): $($s.Why)") }
foreach ($f in $failed) {
$summary.Add("")
$summary.Add("$($f.Status): $($f.Id) ($($f.Log))")
$tail = @(Get-Content $f.Log -Tail 15)
foreach ($line in $tail) { $summary.Add(" $line") }
}
Set-Content (Join-Path $LogDir "summary.txt") $summary
Write-Host ""
$summary | ForEach-Object { Write-Host $_ }
exit [math]::Min($failed.Count, 1)

234
scripts/Run-GameTest.ps1 Normal file
View file

@ -0,0 +1,234 @@
#Requires -Version 7
<#
.SYNOPSIS
Logs a test character in, has RynthAi run the self-test meta (RynthSuite GameTests\RynthSelfTest.af)
and prints what passed. Exit 0 when nothing failed.
.DESCRIPTION
The meta tests RynthAi in game, one check after another: a force rebuff, a kill, looting the corpse,
and missile crafting from bundles with the ammo taken off. It saves rt_<check> = PASS / FAIL / SKIP
and the reason in the character's RynthAi\pvars\<name>.txt, which this script reads. A check the
character can't do (no bow, no monster in view) is a SKIP, not a FAIL.
The client is launched the way Test-ClrWorld.ps1 launches one: the injector's headless --launch with
a saved account profile (the password stays in the launcher's settings), the test engine settings,
its own panel layout, and its OWN dispatch file. Commands go only to that client; the shared
%APPDATA%\RynthCore\dispatch.txt would reach every running client. Plugins are the installed ones
(C:\Games\RynthSuite), so this tests what is deployed on this PC.
-ClientPid runs it in a client that is already in the world instead (logging the same account in
again would drop that one). Commands then go through RynthRemote's per-client command files
(C:\Games\RynthCore\Logs\status\commands\RynthCore.<pid>.*.cmd.json, the phone remote's path), which
only that client reads, and the client is left running.
The meta switches Combat, Buffing, Looting and Nav on and off and puts them back when it finishes.
At the end a client this script launched is closed normally (as the window's close button does)
unless -Keep.
Only point it at a character that may fight and loot where it stands, on a server you run or
may test on. The character should stand near easy monsters; for the crafting check it needs a
bow, crossbow or atlatl and arrowhead and shaft bundles, and no finished ammo to test making it.
.EXAMPLE
.\scripts\Run-GameTest.ps1 # +Buffi on the local ACEmulator server
.EXAMPLE
.\scripts\Run-GameTest.ps1 -Account <account> -Server Aelrynth -Character Freya -Keep
.EXAMPLE
.\scripts\Run-GameTest.ps1 -ClientPid 52000 # Freya, already logged in
#>
param(
[string]$Account = "Buffi",
[string]$Server = "ACEmulator",
[string]$Character = "+Buffi",
[string]$RynthSuiteRoot = "", # defaults to ..\RynthSuite beside this RynthCore
[string]$Runtime = "C:\Games\RynthCore\Runtime",
[string]$Settings = "C:\Games\RynthCore\Test\engine-plugins.json",
[string]$SuiteDir = "C:\Games\RynthSuite",
[int]$LoginTimeoutSeconds = 120,
[int]$TimeoutMinutes = 15, # the meta itself gives up on each check well before this
[int]$ClientPid = 0, # a client already in the world: test in it (no launch, left running)
[switch]$Keep # leave the client running afterwards
)
$ErrorActionPreference = "Stop"
$repo = Split-Path $PSScriptRoot -Parent
if (-not $RynthSuiteRoot) { $RynthSuiteRoot = Join-Path (Split-Path $repo -Parent) "RynthSuite" }
$metaSource = Join-Path $RynthSuiteRoot "GameTests\RynthSelfTest.af"
if (-not (Test-Path $metaSource)) { throw "No self-test meta at $metaSource (pass -RynthSuiteRoot)" }
$metaDir = Join-Path $SuiteDir "RynthAi\MetaFiles"
$pvarsDir = Join-Path $SuiteDir "RynthAi\pvars"
if (-not (Test-Path $metaDir)) { throw "No RynthAi meta folder at $metaDir" }
if ($ClientPid) {
# A running client: its character from the engine's status file, its commands through RynthRemote.
if (-not (Get-Process -Id $ClientPid -ErrorAction SilentlyContinue)) { throw "no process $ClientPid" }
$statusFile = "C:\Games\RynthCore\Logs\status\RynthCore.$ClientPid.status.json"
if (-not (Test-Path $statusFile)) { throw "no engine status for client $ClientPid ($statusFile)" }
$status = Get-Content $statusFile -Raw | ConvertFrom-Json
if (-not $status.inWorld) { throw "client $ClientPid isn't in the world" }
if (-not $PSBoundParameters.ContainsKey("Character")) { $Character = $status.character }
elseif ($Character -ne $status.character) { throw "client $ClientPid is $($status.character), not $Character" }
$log = "C:\Games\RynthCore\Logs\RynthCore.$ClientPid.log"
if (-not (Select-String -Path $log -Pattern "loaded RynthCore\.Plugin\.RynthRemote\.dll" -Quiet)) {
throw "client $ClientPid hasn't loaded RynthRemote, which takes the commands"
}
} else {
$injector = "$repo\out\injector\RynthCore.Injector.exe"
if (-not (Test-Path $injector)) {
dotnet publish "$repo\src\RynthCore.Injector\RynthCore.Injector.csproj" -c Release -o "$repo\out\injector" -nologo -v q | Out-Null
if (-not (Test-Path $injector)) { throw "could not build the injector" }
}
}
# The meta goes in as RynthSelfTest.af. /ra meta load of a name that isn't there would create and
# load a BLANK meta, so the copy is checked first, and the run is checked to have started below.
Copy-Item $metaSource (Join-Path $metaDir "RynthSelfTest.af") -Force
if ((Get-FileHash $metaSource).Hash -ne (Get-FileHash (Join-Path $metaDir "RynthSelfTest.af")).Hash) { throw "the meta did not copy to $metaDir" }
# The character's pvars file: its name with the characters Windows won't take in a file name as '_'
# (ExpressionEngine.SanitizeFileName).
$invalid = [IO.Path]::GetInvalidFileNameChars()
$fileName = -join ($Character.ToCharArray() | ForEach-Object { if ($invalid -contains $_) { '_' } else { $_ } })
$pvars = Join-Path $pvarsDir "$fileName.txt"
# True when the log has a heartbeat written since $since (by its time of day, past midnight too)
# that says the character is in the world (login=1) with plugins ticking (plug=N/s, N > 0).
function Test-ReadySince([string]$logPath, [datetime]$since) {
if (-not (Test-Path $logPath)) { return $false }
$window = ((Get-Date) - $since).TotalSeconds + 5
foreach ($m in Select-String -Path $logPath -Pattern '^\[(\d\d):(\d\d):(\d\d)\.\d+\] .*hb #\d+ .*plug=([1-9]\d*)/s.*login=1') {
$g = $m.Matches[0].Groups
$at = New-TimeSpan -Hours ([int]$g[1].Value) -Minutes ([int]$g[2].Value) -Seconds ([int]$g[3].Value)
$d = ($at - $since.TimeOfDay).TotalSeconds
if ($d -lt -2) { $d += 86400 }
if ($d -ge -2 -and $d -le $window) { return $true }
}
return $false
}
function Read-Results {
$r = @{}
if (Test-Path $pvars) {
foreach ($line in Get-Content $pvars) {
$i = $line.IndexOf("`t")
if ($i -gt 0 -and $line.StartsWith("rt_")) { $r[$line.Substring(0, $i)] = $line.Substring($i + 1) }
}
}
return $r
}
$started = [DateTimeOffset]::UtcNow.ToUnixTimeSeconds()
if ($ClientPid) {
# $gamePid, not $clientPid: PowerShell names ignore case, so that would BE the -ClientPid parameter,
# and a launch would then read as "already in the world" and skip the wait (2026-10-22).
$gamePid = $ClientPid
$commandDir = "C:\Games\RynthCore\Logs\status\commands"
New-Item -ItemType Directory -Force $commandDir | Out-Null
# The file the status agent writes for a phone command (LocalStatusServer.cs): RynthRemote in that
# client takes RynthCore.<its pid>.*.cmd.json in name order and hands "sendchat" to RynthAi.
function Send([string]$command) {
$name = "RynthCore.$gamePid.$('{0:D19}' -f [DateTime]::UtcNow.Ticks)-$([Guid]::NewGuid().ToString('N')).cmd.json"
$json = @{ pid = $gamePid; action = "sendchat"; value = $command; ts = [DateTimeOffset]::UtcNow.ToString("o") } | ConvertTo-Json -Compress
Set-Content "$commandDir\$name.tmp" $json -NoNewline
Move-Item "$commandDir\$name.tmp" "$commandDir\$name" -Force
Start-Sleep 2
}
Write-Host "Testing in client $gamePid ($Character), log $log"
} else {
# The same isolation as Test-ClrWorld.ps1: test engine settings, its own panel layout, its own dispatch file.
$env:RYNTHCORE_ENGINE_SETTINGS = $Settings
$env:RYNTHCORE_TEST_CLIENT = "Run-GameTest"
$env:LOCALAPPDATA = "C:\Games\RynthCore\Test\localappdata"
New-Item -ItemType Directory -Force $env:LOCALAPPDATA | Out-Null
$dispatch = "C:\Games\RynthCore\Test\dispatch-gametest.txt"
$env:RYNTHCORE_DISPATCH_FILE = $dispatch
Set-Content $dispatch "# Run-GameTest dispatch file"
function Send([string]$command) { Set-Content $dispatch "force:$command"; Start-Sleep 2 }
Write-Host "Launching $Character ($Account on $Server)..."
$launchedAt = Get-Date
$out = & $injector --launch --account $Account --server $Server --engine "$Runtime\RynthCore.Loader.dll" --character $Character 2>&1
$m = $out | Select-String "LAUNCHED_PID=(\d+)"
if (-not $m) { $out | ForEach-Object { Write-Host " $_" }; throw "the injector didn't launch a client" }
$gamePid = [int]$m.Matches[0].Groups[1].Value
$log = "C:\Games\RynthCore\Logs\RynthCore.$gamePid.log"
Write-Host "client $gamePid, log $log"
}
$exit = 1
try {
if (-not $ClientPid) {
# In the world with plugins running: a heartbeat written since the launch says login=1 and
# plug=N/s with N > 0. Only lines since the launch count: pids are reused and logs kept, so
# RynthCore.<pid>.log can hold an old client's "login=1" (2026-10-22: the commands went out
# before RynthAi had loaded, and the run never started).
$deadline = (Get-Date).AddSeconds($LoginTimeoutSeconds)
while (-not (Test-ReadySince $log $launchedAt)) {
if (-not (Get-Process -Id $gamePid -ErrorAction SilentlyContinue)) { throw "the client exited before logging in" }
if ((Get-Date) -gt $deadline) { throw "not in the world with plugins running after $LoginTimeoutSeconds s" }
Start-Sleep 3
}
Start-Sleep 10 # plugins settle (RynthAi loads its profile, the character's own meta may start)
}
# A meta's rules run only with the macro on AND RynthAi's Meta switch on (Freya's was off on the
# first run, 2026-10-22: the meta loaded and nothing happened). Put the switch back afterwards.
$statusFile = "C:\Games\RynthCore\Logs\status\RynthCore.$gamePid.status.json"
$metaWasOn = $true
try { $metaWasOn = [bool](Get-Content $statusFile -Raw | ConvertFrom-Json).bot.metaEnabled } catch { }
Send "/ra stop"
Send "/ra meta load RynthSelfTest"
Send "/vt opt set EnableMeta true"
Send "/ra start"
# Started: the meta's Default state writes rt_status RUNNING and rt_started (unix seconds).
$deadline = (Get-Date).AddSeconds(45)
do {
Start-Sleep 3
$r = Read-Results
$fresh = $r.ContainsKey("rt_started") -and [long]$r["rt_started"] -ge $started
if ((Get-Date) -gt $deadline) { throw "the self-test meta didn't start within 45 s (no fresh rt_started in $pvars)" }
} until ($fresh)
Write-Host "the self-test meta is running"
$deadline = (Get-Date).AddMinutes($TimeoutMinutes)
$shown = @{}
do {
Start-Sleep 5
if (-not (Get-Process -Id $gamePid -ErrorAction SilentlyContinue)) { throw "the client exited during the test" }
$r = Read-Results
foreach ($k in "rt_buff", "rt_fight", "rt_loot", "rt_craft") {
if ($r[$k] -and $r[$k] -ne "PENDING" -and -not $shown[$k]) {
$shown[$k] = $true
Write-Host (" {0,-6} {1}" -f $r[$k], $k.Substring(3))
}
}
if ((Get-Date) -gt $deadline) { throw "the self-test meta didn't finish within $TimeoutMinutes minutes" }
} until ($r["rt_status"] -eq "DONE" -and $r.ContainsKey("rt_finished") -and [long]$r["rt_finished"] -ge $started)
Write-Host ""
$names = [ordered]@{ meta = "self-test meta"; buff = "buffing"; fight = "fight (a kill)"; loot = "looting"; craft = "missile crafting" }
$fails = 0
foreach ($k in $names.Keys) {
$result = $r["rt_$k"]; $why = $r["rt_${k}_why"]
if ($result -eq "FAIL" -or -not $result) { $fails++ }
$color = switch ($result) { "PASS" { "Green" } "SKIP" { "Yellow" } default { "Red" } }
Write-Host ("{0,-5} {1,-17} {2}" -f $result, $names[$k], $why) -ForegroundColor $color
}
Write-Host ""
Write-Host $(if ($fails -eq 0) { "No failures." } else { "$fails check(s) failed." })
$exit = [math]::Min($fails, 1)
}
finally {
$p = Get-Process -Id $gamePid -ErrorAction SilentlyContinue
if ($p -and (Get-Variable metaWasOn -ErrorAction SilentlyContinue) -and -not $metaWasOn) {
Send "/ra stop" # the meta stops the macro when it finishes; this covers a run that didn't
Send "/vt opt set EnableMeta false"
}
if ($p -and -not $Keep -and -not $ClientPid) {
# The normal close path (plugins stopped, engine shut down, logged off), not a kill.
[void]$p.CloseMainWindow()
if (-not $p.WaitForExit(30000)) { Write-Warning "client $gamePid didn't close within 30 s; left running" }
else { Write-Host "client closed" }
}
}
exit $exit