[CmdletBinding()]
param(
    [string]$Preset = "desktop-fast",
    [string]$Configuration = "Debug"
)

$ErrorActionPreference = "Stop"
$started = Get-Date

& ctest --preset $Preset --build-config $Configuration
$exitCode = $LASTEXITCODE
$elapsed = [int]((Get-Date) - $started).TotalMilliseconds

[ordered]@{
    command = "test"
    preset = $Preset
    configuration = $Configuration
    exitCode = $exitCode
    elapsedMs = $elapsed
} | ConvertTo-Json -Compress

exit $exitCode
