Skip to content

Commit

Permalink
Misc changes from lukebakken/amqp-string
Browse files Browse the repository at this point in the history
* Add `RunTestsUntilFailure` to `build.ps1`
  • Loading branch information
lukebakken committed May 22, 2024
1 parent 7057fd5 commit 83d37a6
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,36 +1,45 @@
[CmdletBinding(PositionalBinding=$false)]
param(
[switch]$RunTests
[switch]$RunTests,
[switch]$RunTestsUntilFailure
)

$ErrorActionPreference = 'Stop'
Set-StrictMode -Version Latest
$PSNativeCommandUseErrorActionPreference = $true

Write-Host "Run Parameters:" -ForegroundColor Cyan
Write-Host "`tPSScriptRoot: $PSScriptRoot"
Write-Host "`tRunTests: $RunTests"
Write-Host "`tRunTestsUntilFailure: $RunTestsUntilFailure"
Write-Host "`tdotnet --version: $(dotnet --version)"

Write-Host "[INFO] building all projects (Build.csproj traversal)..." -ForegroundColor "Magenta"
dotnet build "$PSScriptRoot\Build.csproj"
Write-Host "[INFO] done building." -ForegroundColor "Green"

if ($RunTests)
if ($RunTests -or $RunTestsUntilFailure)
{
$tests_dir = Join-Path -Path $PSScriptRoot -ChildPath 'projects' | Join-Path -ChildPath 'Test'
$unit_csproj_file = Resolve-Path -LiteralPath (Join-Path -Path $tests_dir -ChildPath 'Unit' | Join-Path -ChildPath 'Unit.csproj')
$integration_csproj_file = Resolve-Path -LiteralPath (Join-Path -Path $tests_dir -ChildPath 'Integration' | Join-Path -ChildPath 'Integration.csproj')
$sequential_integration_csproj_file = Resolve-Path -LiteralPath (Join-Path -Path $tests_dir -ChildPath 'SequentialIntegration' | Join-Path -ChildPath 'SequentialIntegration.csproj')

foreach ($csproj_file in $unit_csproj_file, $integration_csproj_file, $sequential_integration_csproj_file)
Do
{
Write-Host "[INFO] running Unit / Integration tests from '$csproj_file' (all frameworks)" -ForegroundColor "Magenta"
dotnet test $csproj_file --environment 'RABBITMQ_LONG_RUNNING_TESTS=true' --no-restore --no-build --logger "console;verbosity=detailed"
if ($LASTEXITCODE -ne 0)
{
Write-Host "[ERROR] tests errored, exiting" -Foreground "Red"
Exit 1
}
else
foreach ($csproj_file in $unit_csproj_file, $integration_csproj_file, $sequential_integration_csproj_file)
{
Write-Host "[INFO] tests passed" -ForegroundColor "Green"
Write-Host "[INFO] running Unit / Integration tests from '$csproj_file' (all frameworks)" -ForegroundColor "Magenta"
& dotnet test $csproj_file --environment 'RABBITMQ_LONG_RUNNING_TESTS=true' --no-restore --no-build --logger "console;verbosity=detailed"
if ($LASTEXITCODE -ne 0)
{
Write-Host "[ERROR] tests errored, exiting" -Foreground "Red"
Exit 1
}
else
{
Write-Host "[INFO] tests passed" -ForegroundColor "Green"
}
}
}
} While ($RunTestsUntilFailure)
}

0 comments on commit 83d37a6

Please sign in to comment.