Test suite: add --config-dir isolation, --smoke-test alias, and a cold-start/close gate step

Adopted from Andre's RemSound-smoke-test-agent-brief.md - the gaps our pack didn't
already cover:

- --config-dir <folder>: redirect ALL user state (config, profiles, logs, cue
  sounds) to an explicit folder for this process only, applied at the very start of
  Program.Main before the layout migration runs. Lets a test exercise a real build
  without touching the user's live settings (the brief's safety rule 1). Works with
  every command. AppConfig gains SetUserDataDirectoryOverride / an override on
  UserDataDirectory; CommandLine.TryGetConfigDir parses it early.
- --smoke-test / --smoketest: alias for --selftest, matching the brief's vocabulary.
- run-tests.ps1: a cold-start + clean-close smoke (brief baseline steps 3-4) -
  launches the GUI minimized against an isolated --config-dir, confirms it stays up,
  that it used the isolated folder (real settings untouched), and that --close shuts
  it down with no orphan process. SKIPs cleanly if a RemSound instance is already
  running (machine-wide single-instance lock).

Manual + --help updated for both switches.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Ednunp
2026-06-12 23:12:22 +01:00
co-authored by Claude Opus 4.8
parent 141c5e8ce1
commit 832ed40bf7
6 changed files with 93 additions and 5 deletions
+36
View File
@@ -113,6 +113,42 @@ foreach ($line in ($st.Text -split "`r?`n")) {
}
if ($st.Code -eq 0) { Pass "self-test passed (exit 0)" } else { Fail "self-test failed (exit $($st.Code))" }
# ---- 5. COLD START + CLEAN CLOSE, against an isolated --config-dir so the real settings are never
# touched (smoke-test brief, safety rule 1 + baseline steps 3-4) ----
Write-Host "`nCold start and clean close (isolated config):" -ForegroundColor Cyan
$already = @(Get-Process RemSound -ErrorAction SilentlyContinue)
if ($already.Count -gt 0) {
Write-Host " [SKIP] a RemSound instance is already running (machine-wide single-instance lock) - close it to run this check" -ForegroundColor Yellow
}
else {
$testCfg = Join-Path ([System.IO.Path]::GetTempPath()) ("rs-cfg-" + [guid]::NewGuid().ToString('N'))
$proc = $null
try {
$proc = Start-Process -FilePath $exe -ArgumentList @('--config-dir', $testCfg, '--connect', '127.0.0.1', '--minimized') -PassThru
Start-Sleep -Seconds 6
if (Get-Process -Id $proc.Id -ErrorAction SilentlyContinue) { Pass "GUI cold-started and stayed up (minimized to tray)" }
else { Fail "GUI exited or crashed during cold start" }
# Startup consolidates the cue sounds into UserDataDirectory; with the override that's $testCfg,
# so a populated $testCfg proves the process honoured --config-dir and left the real settings alone.
if (Test-Path (Join-Path $testCfg 'sounds')) { Pass "ran against the isolated --config-dir folder (real settings untouched)" }
else { Fail "--config-dir folder was not populated - config isolation may not be working" }
Invoke-RsCli @('--close') | Out-Null
Start-Sleep -Seconds 2
$still = Get-Process -Id $proc.Id -ErrorAction SilentlyContinue
if (-not $still) { Pass "--close shut the GUI down cleanly (no orphan process)" }
else { Fail "process still running after --close"; try { $still | Stop-Process -Force } catch { } }
}
catch {
Fail "cold-start/close smoke threw: $($_.Exception.Message)"
if ($proc) { try { Get-Process -Id $proc.Id -ErrorAction SilentlyContinue | Stop-Process -Force } catch { } }
}
finally {
Remove-Item -LiteralPath $testCfg -Recurse -Force -ErrorAction SilentlyContinue
}
}
# ---- summary ----
Remove-Item -LiteralPath $publishDir -Recurse -Force -ErrorAction SilentlyContinue
Write-Host ""