Skip to content

Commit

Permalink
fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
lemeurherve committed Feb 26, 2024
1 parent 66a22a4 commit d06c10a
Showing 1 changed file with 40 additions and 39 deletions.
79 changes: 40 additions & 39 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -121,48 +121,49 @@ if($lastExitCode -ne 0) {
}

if($target -eq "test") {
if ($DryRun) {
Write-Host "= TEST: (dry-run) test harness"
} else {
Write-Host "= TEST: Starting test harness"

$mod = Get-InstalledModule -Name Pester -MinimumVersion 5.3.0 -MaximumVersion 5.3.3 -ErrorAction SilentlyContinue
if($null -eq $mod) {
Write-Host "= TEST: Pester 5.3.x not found: installing..."
$module = "c:\Program Files\WindowsPowerShell\Modules\Pester"
if(Test-Path $module) {
takeown /F $module /A /R
icacls $module /reset
icacls $module /grant Administrators:'F' /inheritance:d /T
Remove-Item -Path $module -Recurse -Force -Confirm:$false
if ($DryRun) {
Write-Host "= TEST: (dry-run) test harness"
} else {
Write-Host "= TEST: Starting test harness"

$mod = Get-InstalledModule -Name Pester -MinimumVersion 5.3.0 -MaximumVersion 5.3.3 -ErrorAction SilentlyContinue
if($null -eq $mod) {
Write-Host "= TEST: Pester 5.3.x not found: installing..."
$module = "c:\Program Files\WindowsPowerShell\Modules\Pester"
if(Test-Path $module) {
takeown /F $module /A /R
icacls $module /reset
icacls $module /grant Administrators:'F' /inheritance:d /T
Remove-Item -Path $module -Recurse -Force -Confirm:$false
}
Install-Module -Force -Name Pester -MaximumVersion 5.3.3
}
Install-Module -Force -Name Pester -MaximumVersion 5.3.3
}

Import-Module Pester
Write-Host "= TEST: Setting up Pester environment..."
$configuration = [PesterConfiguration]::Default
$configuration.Run.PassThru = $true
$configuration.Run.Path = '.\tests'
$configuration.Run.Exit = $true
$configuration.TestResult.Enabled = $true
$configuration.TestResult.OutputFormat = 'JUnitXml'
$configuration.Output.Verbosity = 'Diagnostic'
$configuration.CodeCoverage.Enabled = $false

Write-Host "= TEST: Testing all ${agentType} images..."
# Only fail the run afterwards in case of any test failures
$testFailed = $false
foreach($image in $builds) {
$testFailed = $testFailed -or (Test-Image $image)
}
Import-Module Pester
Write-Host "= TEST: Setting up Pester environment..."
$configuration = [PesterConfiguration]::Default
$configuration.Run.PassThru = $true
$configuration.Run.Path = '.\tests'
$configuration.Run.Exit = $true
$configuration.TestResult.Enabled = $true
$configuration.TestResult.OutputFormat = 'JUnitXml'
$configuration.Output.Verbosity = 'Diagnostic'
$configuration.CodeCoverage.Enabled = $false

Write-Host "= TEST: Testing all ${agentType} images..."
# Only fail the run afterwards in case of any test failures
$testFailed = $false
foreach($image in $builds) {
$testFailed = $testFailed -or (Test-Image $image)
}

# Fail if any test failures
if($testFailed -ne $false) {
Write-Error "= TEST: stage failed!"
exit 1
} else {
Write-Host "= TEST: stage passed!"
# Fail if any test failures
if($testFailed -ne $false) {
Write-Error "= TEST: stage failed!"
exit 1
} else {
Write-Host "= TEST: stage passed!"
}
}
}

Expand Down

0 comments on commit d06c10a

Please sign in to comment.