Skip to content

Commit 8aa2157

Browse files
committed
Update pester in automation helper test
1 parent e4e2a7a commit 8aa2157

File tree

10 files changed

+760
-404
lines changed

10 files changed

+760
-404
lines changed

ci/pipelines/stemcells-windows.yml

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,6 @@ resources:
160160
type: git
161161
source:
162162
uri: https://github.com/cloudfoundry/windows-utilities-release.git
163-
- name: pester
164-
type: git
165-
source:
166-
uri: https://github.com/pester/Pester.git
167-
tag_filter: 4.4.0
168163
- name: bosh-windows-acceptance-tests-src-out
169164
type: git
170165
source:
@@ -686,9 +681,17 @@ jobs:
686681
- get: bosh-windows-stemcell-builder-ci
687682
- get: stemcell-builder
688683
trigger: true
689-
- task: test-units-bosh-psmodules
690-
file: bosh-windows-stemcell-builder-ci/ci/tasks/test-units-bosh-psmodules/task.yml
691-
tags: [windows-nimbus]
684+
- in_parallel:
685+
- task: test-units-bosh-psmodules
686+
file: bosh-windows-stemcell-builder-ci/ci/tasks/test-units-bosh-psmodules/task.yml
687+
tags: [windows-nimbus]
688+
params:
689+
MODULES_DIR: modules
690+
- task: test-units-bosh-psmodules-stembuild
691+
file: bosh-windows-stemcell-builder-ci/ci/tasks/test-units-bosh-psmodules/task.yml
692+
tags: [windows-nimbus]
693+
params:
694+
MODULES_DIR: stembuild/modules
692695
- name: test-stemcell-builder
693696
serial: true
694697
plan:
@@ -822,7 +825,6 @@ jobs:
822825
steps:
823826
- get: bosh-windows-stemcell-builder-ci
824827
- get: bosh-windows-stemcell-builder-ci-image
825-
- get: pester
826828
- get: open-ssh
827829
resource: openssh-release
828830
- get: stemcell-builder
@@ -932,7 +934,6 @@ jobs:
932934
steps:
933935
- get: bosh-windows-stemcell-builder-ci
934936
- get: bosh-windows-stemcell-builder-ci-image
935-
- get: pester
936937
- get: open-ssh
937938
resource: openssh-release
938939
- get: stemcell-builder

ci/tasks/test-units-bosh-psmodules/run.ps1

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ function New-TemporaryDirectory {
33
$name = (New-Guid).ToString("N")
44
New-Item -ItemType Directory -Path (Join-Path $tmp $name)
55
}
6-
76
$moduleDir = New-TemporaryDirectory
87
$pesterModule = Find-Module -Name Pester -MaximumVersion "5.9999" -MinimumVersion "5.0"
98
$pesterModule | Save-Module -Path $moduleDir
10-
119
Import-Module "$moduleDir\Pester\$($pesterModule.Version)\Pester.psm1"
1210

1311
$status = (Get-Service -Name "wuauserv").Status
@@ -17,7 +15,7 @@ $startupType = Get-Service "wuauserv" | Select-Object -ExpandProperty StartType
1715

1816
$result = 0
1917

20-
$testModules = Get-ChildItem "./bosh-psmodules-repo/modules/" -recurse | where {$_.name -match ".*.Tests.ps1"} | foreach {$_.DirectoryName}
18+
$testModules = Get-ChildItem "./stemcell-builder/$env:MODULES_DIR" -recurse | where {$_.name -match ".*.Tests.ps1"} | foreach {$_.DirectoryName}
2119
foreach ($module in $testModules) {
2220
Write-Host "Testing: $module"
2321
Push-Location "$module"
@@ -33,6 +31,5 @@ foreach ($module in $testModules) {
3331
Pop-Location
3432
}
3533

36-
echo "Failed Tests: $result"
34+
echo "Failed Test Count: $result"
3735
exit $result
38-

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ inputs:
55
- name: bosh-windows-stemcell-builder-ci
66
- name: stemcell-builder
77

8+
params:
9+
MODULES_DIR:
10+
811
run:
912
path: powershell
1013
args:

ci/tasks/test-units-stemcell-automation/task.yml

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,37 @@ platform: windows
33
inputs:
44
- name: bosh-windows-stemcell-builder-ci
55
- name: stemcell-builder
6-
- name: pester
6+
7+
params:
8+
STEMCELL_AUTOMATION_DIR: stemcell-builder/stembuild/stemcell-automation/
79

810
run:
911
path: powershell
1012
args:
1113
- "-Command"
12-
- "& {
13-
Import-Module ./bosh-windows-stemcell-builder-ci/ci/common-scripts/setup-windows-container.psm1;
14-
Set-TmpDir;
15-
Import-Module ./Pester/pester.psm1;
16-
pushd stemcell-builder/stembuild/stemcell-automation;
17-
$result=Invoke-Pester -PassThru;
18-
popd;
19-
Write-Host \"Failed Tests:\"$result.FailedCount;
20-
exit $result.FailedCount
21-
}"
14+
- |
15+
& {
16+
function New-TemporaryDirectory {
17+
$tmp = [System.IO.Path]::GetTempPath() # Not $env:TEMP, see https://stackoverflow.com/a/946017
18+
$name = (New-Guid).ToString("N")
19+
New-Item -ItemType Directory -Path (Join-Path $tmp $name)
20+
}
21+
$moduleDir = New-TemporaryDirectory
22+
$pesterModule = Find-Module -Name Pester -MaximumVersion "5.9999" -MinimumVersion "5.0"
23+
$pesterModule | Save-Module -Path $moduleDir
24+
Import-Module "$moduleDir\Pester\$($pesterModule.Version)\Pester.psm1"
25+
26+
Import-Module ./bosh-windows-stemcell-builder-ci/ci/common-scripts/setup-windows-container.psm1
27+
28+
Set-TmpDir
29+
pushd $env:STEMCELL_AUTOMATION_DIR
30+
# NOTE: uncomment the lines below to see full stack trace
31+
# $configuration = New-PesterConfiguration
32+
# $configuration.Output.StackTraceVerbosity = "Full"
33+
# $result=Invoke-Pester -Configuration $configuration
34+
$result=Invoke-Pester -PassThru
35+
popd;
36+
37+
Write-Host "Failed Test Count:"$result.FailedCount
38+
exit $result.FailedCount
39+
}

stembuild/modules/BOSH.CFCell/BOSH.CFCell.Tests.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ BeforeAll {
88

99
Describe "Protect-CFCell" {
1010
BeforeEach {
11+
Mock -ModuleName BOSH.CFCell Write-Log { }
12+
1113
$oldWinRMStatus = (Get-Service winrm).Status
1214
$oldWinRMStartMode = ( Get-Service winrm ).StartType
1315

0 commit comments

Comments
 (0)