add pester debug output

This commit is contained in:
OCram85 2020-06-04 09:23:55 +02:00
parent 9b2ca57a8d
commit b0a5ccd192
2 changed files with 63 additions and 15 deletions

View File

@ -28,6 +28,8 @@ environment:
secure: 835qfZIkC9mE7QhkYfOZVAdR8rZhPvxG8BO4CbeaelRQOhlqmaSr8G1DWRJzZ/bS secure: 835qfZIkC9mE7QhkYfOZVAdR8rZhPvxG8BO4CbeaelRQOhlqmaSr8G1DWRJzZ/bS
CoverallsToken: CoverallsToken:
secure: eTjWqHL48MBr8wp1rSgLrXHdtpfDV/uClacP3svlWJfCvn/zVokpuaMnWM5RoyIY secure: eTjWqHL48MBr8wp1rSgLrXHdtpfDV/uClacP3svlWJfCvn/zVokpuaMnWM5RoyIY
CodeCovToken:
secure: LJOvamWIlVORDE7120KcmWVkHxOFYBSN99linyICXXmXLtYm81K/31YeMGiPlgTm
build: false build: false
@ -38,14 +40,19 @@ build_script:
- ps: Invoke-AppVeyorBuild - ps: Invoke-AppVeyorBuild
test_script: test_script:
#- ps: |
# $CodeCoverage = Invoke-AppVeyorTests
# if ($null -ne $Env:CoverallsToken) {
# Invoke-CoverageReport -PesterCoverageReport $CodeCoverage
# }
# else {
# Write-Warning "No CoverallsToken found. This build seems to be triggered by a PR. Skipping this step..."
# }
- ps: | - ps: |
$CodeCoverage = Invoke-AppVeyorTests Invoke-CodeCoveTests
if ($null -ne $Env:CoverallsToken) { $env:PATH = 'C:\msys64\usr\bin;' + $env:PATH
Invoke-CoverageReport -PesterCoverageReport $CodeCoverage Invoke-WebRequest -Uri 'https://codecov.io/bash' -OutFile codecov.sh
} bash codecov.sh -f "coverage.xml" -t $Env:CodeCovToken
else {
Write-Warning "No CoverallsToken found. This build seems to be triggered by a PR. Skipping this step..."
}
deploy: deploy:
#- provider: GitHub #- provider: GitHub
@ -67,7 +74,6 @@ deploy:
after_deploy: after_deploy:
- ps: Invoke-AppVeyorPSGallery -OnBranch 'master' - ps: Invoke-AppVeyorPSGallery -OnBranch 'master'
# Pause build until `lock` on desktop is deleted. # Pause build until `lock` on desktop is deleted.
#on_finish: #on_finish:
# - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) # - ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))

View File

@ -16,13 +16,19 @@ Function Invoke-InstallDependencies() {
Process { Process {
Try { Try {
Write-Host 'Available PS modules are:' -ForegroundColor Green -BackgroundColor Black
Get-Module -ListAvailable -Name Pester | Format-Table | Out-String
Get-PackageProvider -ListAvailable Get-PackageProvider -ListAvailable
Install-PackageProvider -Name NuGet -RequiredVersion '2.8.5.208' -Force -Verbose Install-PackageProvider -Name NuGet -RequiredVersion '2.8.5.208' -Force -Verbose
Import-PackageProvider -Name NuGet -RequiredVersion '2.8.5.208' -Force Import-PackageProvider -Name NuGet -RequiredVersion '2.8.5.208' -Force
Install-Module -Name 'Pester' -Scope CurrentUser -RequiredVersion '4.4.2' -Force -SkipPublisherCheck -AllowClobber Write-Host 'Installing build deps...' -ForegroundColor Red -BackgroundColor Black
Install-Module -Name 'Pester' -Scope CurrentUser -RequiredVersion '4.10.1' -Force -SkipPublisherCheck -AllowClobber -Verbose
Install-Module -Name 'posh-git' -Scope CurrentUser -RequiredVersion '1.0.0-beta2' -Force -SkipPublisherCheck -AllowClobber -AllowPrerelease Install-Module -Name 'posh-git' -Scope CurrentUser -RequiredVersion '1.0.0-beta2' -Force -SkipPublisherCheck -AllowClobber -AllowPrerelease
Install-Module -Name 'PSCoverage' -Scope CurrentUser -Force -SkipPublisherCheck -AllowClobber -RequiredVersion '1.0.78' #Install-Module -Name 'PSCoverage' -Scope CurrentUser -Force -SkipPublisherCheck -AllowClobber -RequiredVersion '1.0.78'
Import-Module -Name 'Pester', 'posh-git' , 'PSCoverage' Import-Module -Name 'posh-git'
#Import-Module -Name 'PSCoverage'
Remove-Module -Name 'Pester' -Force -ErrorAction SilentlyContinue
Import-Module -Name 'Pester' -RequiredVersion '4.10.1' -Verbose
} }
Catch { Catch {
$MsgParams = @{ $MsgParams = @{
@ -33,7 +39,8 @@ Function Invoke-InstallDependencies() {
Add-AppveyorMessage @MsgParams Add-AppveyorMessage @MsgParams
Throw $MsgParams.Message Throw $MsgParams.Message
} }
Write-Host 'Loaded PS modules are:' -ForegroundColor Green -BackgroundColor Black
Get-Module -Name Pester | Format-Table | Out-String
} }
} }
Function Invoke-AppVeyorBumpVersion() { Function Invoke-AppVeyorBumpVersion() {
@ -174,6 +181,41 @@ Function Invoke-AppVeyorTests() {
} }
Function Invoke-CodeCoveTests() {
[CmdletBinding()]
Param()
$MsgParams = @{
Message = 'Starting Pester tests'
Category = 'Information'
Details = 'Now running all test found in .\tests\ dir.'
}
Add-AppveyorMessage @MsgParams
try {
Write-Host '===== Preload internal private functions =====' -ForegroundColor Black -BackgroundColor Yellow
$Privates = Get-ChildItem -Path (Join-Path -Path $Env:APPVEYOR_BUILD_FOLDER -ChildPath '/src/Private/*') -Include "*.ps1" -Recurse
foreach ($File in $Privates) {
if (Test-Path -Path $File.FullName) {
. $File.FullName
Write-Verbose -Message ('Private function dot-sourced: {0}' -f $File.FullName) -Verbose
}
else {
Write-Warning -Message ('Could not find file: {0} !' -f $File.FullName)
}
}
}
catch {
$_.Exception.Message | Write-Error
throw 'Could not load required private functions!'
}
#$testresults = Invoke-Pester -Path ( Get-ChildItem -Path ".\tests\*.Tests.ps1" -Recurse | Sort-Object -Property Name ) -ExcludeTag 'Disabled' -PassThru
$srcFiles = Get-ChildItem -Path ".\src\*.ps1" -Recurse | Sort-Object -Property 'Name' | Select-Object -ExpandProperty 'FullName'
$testFiles = Get-ChildItem -Path ".\tests\*.Tests.ps1" -Recurse | Sort-Object -Property 'Name' | Select-Object -ExpandProperty 'FullName'
$PesterRes = Invoke-Pester -Path $testFiles -CodeCoverage $srcFiles -CodeCoverageOutputFile ".\coverage.xml" -CodeCoverageOutputFileEncoding ascii -CodeCoverageOutputFileFormat JaCoCo
}
Function Invoke-CoverageReport() { Function Invoke-CoverageReport() {
[CmdletBinding()] [CmdletBinding()]
Param( Param(