Update Start-PSPester and Restore-PSPester cmdlets in build.psm1 to check for Pester 4.2 (#6667)

Update Start-PSPester and Restore-PSPester cmdlets in buil.psm1 to check for Pester 4.2 to support exception passthru.
This commit is contained in:
Klaudia Algiz
2018-04-27 15:34:54 -07:00
committed by Travis Plunk
parent 5fd0d6962b
commit e9b045e819
+12 -2
View File
@@ -683,7 +683,7 @@ function Restore-PSPester
[ValidateNotNullOrEmpty()]
[string] $Destination = ([IO.Path]::Combine((Split-Path (Get-PSOptions -DefaultToNew).Output), "Modules"))
)
Save-Module -Name Pester -Path $Destination -Repository PSGallery
Save-Module -Name Pester -Path $Destination -Repository PSGallery -RequiredVersion "4.2"
}
function Compress-TestContent {
@@ -992,7 +992,8 @@ function Start-PSPester {
[switch]$IncludeFailingTest
)
if (-not (Get-Module -ListAvailable -Name $Pester -ErrorAction SilentlyContinue))
$getModuleResults = Get-Module -ListAvailable -Name $Pester -ErrorAction SilentlyContinue
if (-not $getModuleResults)
{
Write-Warning @"
Pester module not found.
@@ -1002,6 +1003,15 @@ Restore the module to '$Pester' by running:
return;
}
if (-not ($getModuleResults | Where-Object { $_.Version -ge "4.2" } )) {
Write-Warning @"
No Pester module of version 4.2 and higher.
Restore the required module version to '$Pester' by running:
Restore-PSPester
"@
return;
}
if ($IncludeFailingTest.IsPresent)
{
$Path += "$PSScriptRoot/tools/failingTests"