Files
ExecuteR/scripts/Test.ps1
T
Alphaeus Mote 13742a1087
CI / build-test (push) Successful in 42m14s
CI / images (push) Has been skipped
Release / release (push) Successful in 20m21s
Release / images (push) Successful in 6m54s
chore(test): Test.ps1 -IncludeDeploy runs deploy.sh's database decision tests
Release of the work since v1.6.1: bundled Postgres by default, Restart After Run with an agent-held timer and optional warning, S3 pre-run downloads, parallel dispatch and batched job states, script sequences, parallel upgrade fan-out and the reconnect storm fixes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-07 11:23:19 -05:00

66 lines
2.3 KiB
PowerShell

<#
.SYNOPSIS
Runs unit tests (and optionally the WebUI typecheck + lint and the integration tests).
.EXAMPLE
./scripts/Test.ps1
./scripts/Test.ps1 -IncludeIntegration -IncludeWebUI
#>
[CmdletBinding()]
param(
[ValidateSet('Debug', 'Release')]
[string]$Configuration = 'Release',
[string]$Version,
[switch]$IncludeIntegration,
[switch]$IncludeWebUI,
# deploy.sh's database decisions (scripts/tests/Test-DeployDatabase.sh); needs bash (Git Bash on Windows).
[switch]$IncludeDeploy
)
$ErrorActionPreference = 'Stop'
$repoRoot = Split-Path -Parent $PSScriptRoot
$Version = & (Join-Path $PSScriptRoot 'Get-Version.ps1') -Version $Version
$unitProjects = @(
'tests/Shared.Tests',
'tests/Agent.Tests',
'tests/Agent.Watchdog.Tests',
'tests/Backend.Tests'
)
foreach ($project in $unitProjects) {
dotnet test (Join-Path $repoRoot $project) -c $Configuration --nologo "-p:UnifiedVersion=$Version"
if ($LASTEXITCODE -ne 0) { throw "Tests failed in $project ($LASTEXITCODE)." }
}
if ($IncludeIntegration) {
dotnet test (Join-Path $repoRoot 'tests/Integration.Tests') -c $Configuration --nologo "-p:UnifiedVersion=$Version"
if ($LASTEXITCODE -ne 0) { throw "Integration tests failed ($LASTEXITCODE)." }
}
if ($IncludeWebUI) {
Push-Location (Join-Path $repoRoot 'src/WebUI')
try {
if (-not (Test-Path 'node_modules')) {
npm ci
if ($LASTEXITCODE -ne 0) { throw "npm ci failed ($LASTEXITCODE)." }
}
npm run check
if ($LASTEXITCODE -ne 0) { throw "WebUI check (typecheck + lint) failed ($LASTEXITCODE)." }
}
finally {
Pop-Location
}
}
if ($IncludeDeploy) {
# Git Bash first on Windows: System32's bash.exe is WSL's, which cannot take a Windows path.
$gitBash = if ($IsWindows) { Join-Path $env:ProgramFiles 'Git/bin/bash.exe' } else { $null }
$bash = if ($gitBash -and (Test-Path $gitBash)) { Get-Command $gitBash } else { Get-Command bash -ErrorAction SilentlyContinue }
if (-not $bash) { throw 'bash is needed for -IncludeDeploy (Git Bash on Windows).' }
& $bash.Source (Join-Path $repoRoot 'scripts/tests/Test-DeployDatabase.sh')
if ($LASTEXITCODE -ne 0) { throw "Deploy database tests failed ($LASTEXITCODE)." }
}
Write-Host 'All requested test suites passed.'