forked from pester/Pester
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testRelease.ps1
42 lines (34 loc) · 890 Bytes
/
testRelease.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
param(
[switch] $LocalBuild
)
$ErrorActionPreference = 'Stop'
$psd1 = Join-Path $PSScriptRoot Pester.psd1
Get-Module Pester | Remove-Module
Import-Module $psd1 -ErrorAction Stop
$xml = Join-Path $PSScriptRoot Test.Version.xml
$result = Invoke-Pester -Script $PSScriptRoot -Tag VersionChecks, StyleRules, Help -OutputFile $xml -OutputFormat NUnitXml -PassThru -Strict -ErrorAction Stop
if ($LocalBuild) {
# when I build release locally I don't want to
# think about removing the xml all the time
Remove-Item $xml
}
if ($result.TotalCount -lt 1) {
$m = "No tests were run."
if ($LocalBuild) {
$m
exit 9999
}
else {
throw $m
}
}
if ($result.FailedCount -gt 0) {
$m = "$($result.FailedCount) tests did not pass."
if ($LocalBuild) {
$m
exit $result.FailedCount
}
else {
throw $m
}
}