-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
test.ps1
42 lines (35 loc) · 1.49 KB
/
test.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]$Chocolatey,
[switch]$Pester,
[string]$Tag,
[switch]$CodeCoverage
)
$ErrorActionPreference = 'Stop'
if (!$Chocolatey -and !$Pester) { $Chocolatey = $Pester = $true }
$buildDir = Get-Item $PSScriptRoot/.build/*
if ($Chocolatey) {
"`n==| Running Chocolatey tests"
Test-Package $buildDir
}
if ($Pester) {
"`n==| Running Pester tests"
$testResultsFile = "$buildDir/TestResults.xml"
if ($CodeCoverage) {
$files = @(Get-ChildItem $PSScriptRoot/Wormies-AU-Helpers/* -Filter *.ps1 -Recurse | ForEach-Object FullName)
if ((Test-Path Env:\APPVEYOR) -and (Get-Command Export-CodeCovIoJson -ea 0)) {
$res = Invoke-Pester -OutputFormat NUnitXml -OutputFile $testResultsFile -PassThru -CodeCoverage $files -CodeCoverageOutputFile "coverage.xml"
$wc = New-Object 'System.Net.WebClient'
$wc.UploadFile("https://ci.appveyor.com/api/testresults/nunit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path $testResultsFile))
Export-CodeCovIoJson -CodeCoverage $res.CodeCoverage -RepoRoot $PSScriptRoot -Path "coverage.json" | Out-Null
if ($res.FailedCount -gt 0) {
throw "$($res.FailedCount) tests failed"
}
}
else {
$res = Invoke-Pester -Tag $Tag -OutputFormat NUnitXml -OutputFile $testResultsFile -PassThru -CodeCoverage $files
}
}
else {
$res = Invoke-Pester -Tag $Tag -OutputFormat NUnitXml -OutputFile $testResultsFile -PassThru
}
}