From e6891a72ead34c11f97aefec7a6fdb8ec4f0e16a Mon Sep 17 00:00:00 2001 From: Stevan Freeborn Date: Fri, 28 Aug 2026 09:13:59 -0500 Subject: [PATCH] chore: update test script to allow running from anywhere and also clean up test results on each run --- scripts/test.ps1 | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/scripts/test.ps1 b/scripts/test.ps1 index c6a6c01..eddb855 100644 --- a/scripts/test.ps1 +++ b/scripts/test.ps1 @@ -1,22 +1,36 @@ -Write-Host "Starting test execution..." -ForegroundColor Magenta -Write-Host "" +$RepoRoot = Resolve-Path (Join-Path -Path $PSScriptRoot -ChildPath "..") -dotnet test +Push-Location -Path $RepoRoot +try { + Write-Host "Starting test execution..." -ForegroundColor Magenta + Write-Host "" -$TestExitCode = $LASTEXITCODE + $TestResultsPath = Join-Path -Path $RepoRoot -ChildPath "TestResults" -if ($TestExitCode -eq 0) { - Write-Host "" - Write-Host "Tests passed. Generating code coverage HTML report..." -ForegroundColor Magenta - Write-Host "" + if (Test-Path $TestResultsPath) { + Remove-Item -Path $TestResultsPath -Recurse -Force + } - reportgenerator -reports:"**/*.cobertura.xml" -targetdir:"CoverageReport" + dotnet test - Write-Host "" - Write-Host "SUCCESS: All tests passed and coverage report generated." -ForegroundColor Green -} else { - Write-Host "FAILURE: Tests failed with exit code $TestExitCode. Skipping coverage report generation." -ForegroundColor Red + $TestExitCode = $LASTEXITCODE + + if ($TestExitCode -eq 0) { + Write-Host "" + Write-Host "Tests passed. Generating code coverage HTML report..." -ForegroundColor Magenta + Write-Host "" + + reportgenerator -reports:"**/*.cobertura.xml" -targetdir:"CoverageReport" + + Write-Host "" + Write-Host "SUCCESS: All tests passed and coverage report generated." -ForegroundColor Green + } else { + Write-Host "FAILURE: Tests failed with exit code $TestExitCode. Skipping coverage report generation." -ForegroundColor Red + } +} +finally { + Pop-Location } exit $TestExitCode