Skip to content

Commit e9fd48c

Browse files
Alphasitearamprice
authored andcommitted
Update pester invocation script to use Pester 5
It also switches how we fetch pester from a git repo to a binary install. I did try to preserve the old install method but it doesnt work quite right. So instead I went the precompiled binary method.
1 parent f420221 commit e9fd48c

File tree

3 files changed

+25
-9
lines changed

3 files changed

+25
-9
lines changed

ci/pipelines/stemcells-windows-2019.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,6 @@ jobs:
683683
- in_parallel:
684684
fail_fast: true
685685
steps:
686-
- get: pester
687686
- get: bosh-windows-stemcell-builder-ci
688687
- get: stemcell-builder
689688
trigger: true
Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,38 @@
1-
$ErrorActionPreference = "Stop"
2-
# Do not set error action preference let Pester handle it instead
3-
$result = 0
1+
function New-TemporaryDirectory {
2+
$tmp = [System.IO.Path]::GetTempPath() # Not $env:TEMP, see https://stackoverflow.com/a/946017
3+
$name = (New-Guid).ToString("N")
4+
New-Item -ItemType Directory -Path (Join-Path $tmp $name)
5+
}
6+
7+
$moduleDir = New-TemporaryDirectory
8+
$pesterModule = Find-Module -Name Pester -MaximumVersion "5.9999" -MinimumVersion "5.0"
9+
$pesterModule | Save-Module -Path $moduleDir
10+
11+
Import-Module "$moduleDir\Pester\$($pesterModule.Version)\Pester.psm1"
412

5-
Import-Module ./Pester/pester.psm1;
613
$status = (Get-Service -Name "wuauserv").Status
714
$startupType = Get-Service "wuauserv" | Select-Object -ExpandProperty StartType | Out-String
815
"wuauserv status = * $status *"
916
"wuauserv startuptype = * $startupType *"
1017

11-
foreach ($module in (Get-ChildItem "./stemcell-builder/modules").Name) {
12-
Push-Location "./stemcell-builder/modules/$module"
18+
$result = 0
19+
20+
$testModules = Get-ChildItem "./bosh-psmodules-repo/modules/" -recurse | where {$_.name -match ".*.Tests.ps1"} | foreach {$_.DirectoryName}
21+
foreach ($module in $testModules) {
22+
Write-Host "Testing: $module"
23+
Push-Location "$module"
24+
25+
# Do not set $ErrorActionPreference and let Pester handle it nativetly; setting it to Stop globally will
26+
# break the tests since they are written with the assumption non zero exit codes will not fail a test
27+
# See: https://github.com/pester/Pester/issues/1404#issuecomment-568659518 for details
1328
$results=Invoke-Pester -PassThru
1429
if ($results.FailedCount -gt 0) {
1530
$result += $results.FailedCount
1631
}
17-
Pop-Location
32+
33+
Pop-Location
1834
}
35+
1936
echo "Failed Tests: $result"
2037
exit $result
38+

ci/tasks/test-units-bosh-psmodules/task.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ platform: windows
44
inputs:
55
- name: bosh-windows-stemcell-builder-ci
66
- name: stemcell-builder
7-
- name: pester
87

98
run:
109
path: powershell

0 commit comments

Comments
 (0)