From 3a163b2f285f2d77dadbbacd82f18fff08d94d62 Mon Sep 17 00:00:00 2001 From: Christoph Bergmeister Date: Sat, 4 Apr 2020 21:49:05 +0100 Subject: [PATCH] Pin major version of Pester to 4 and upgrade Pester version for WMF4 build --- README.md | 1 + build.psm1 | 5 +++-- tools/appveyor.psm1 | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5a8fe1103..b20f89825 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,7 @@ Note: the PSScriptAnalyzer Chocolatey package is provided and supported by the c #### Requirements * [.NET Core 3.1.102 SDK](https://www.microsoft.com/net/download/dotnet-core/3.1#sdk-3.1.102) or newer patch release +* [Pester v4 PowerShell module, available on PowerShell Gallery](https://github.com/pester/Pester) * [PlatyPS PowerShell module, available on PowerShell Gallery](https://github.com/PowerShell/platyPS/releases) * Optionally but recommended for development: [Visual Studio 2017/2019](https://www.visualstudio.com/downloads/) diff --git a/build.psm1 b/build.psm1 index 5a85e3187..827654bc2 100644 --- a/build.psm1 +++ b/build.psm1 @@ -331,13 +331,14 @@ function Test-ScriptAnalyzer } $savedModulePath = $env:PSModulePath $env:PSModulePath = "${testModulePath}{0}${env:PSModulePath}" -f [System.IO.Path]::PathSeparator + $importPesterV4 = 'Import-Module -Name Pester -MaximumVersion 4.99' if ($ShowAll) { - $scriptBlock = [scriptblock]::Create("Invoke-Pester -Path $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile") + $scriptBlock = [scriptblock]::Create("$importPesterV4; Invoke-Pester -Path $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile") } else { - $scriptBlock = [scriptblock]::Create("Invoke-Pester -Path $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -Show Describe,Summary,Failed") + $scriptBlock = [scriptblock]::Create("$importPesterV4; Invoke-Pester -Path $testScripts -OutputFormat NUnitXml -OutputFile $testResultsFile -Show Describe,Summary,Failed") } if ( $InProcess ) { & $scriptBlock diff --git a/tools/appveyor.psm1 b/tools/appveyor.psm1 index ffbcc415f..3997cedfb 100644 --- a/tools/appveyor.psm1 +++ b/tools/appveyor.psm1 @@ -4,7 +4,7 @@ $ErrorActionPreference = 'Stop' function Install-Pester { - $requiredPesterVersion = '4.10.0' + $requiredPesterVersion = '4.10.1' $pester = Get-Module Pester -ListAvailable | Where-Object { $_.Version -eq $requiredPesterVersion } if ($null -eq $pester) { if ($null -eq (Get-Module -ListAvailable PowershellGet)) { @@ -15,7 +15,7 @@ function Install-Pester { else { # Visual Studio 2017 build (has already Pester v3, therefore a different installation mechanism is needed to make it also use the new version 4) Write-Verbose -Verbose "Installing Pester via Install-Module" - Install-Module -Name Pester -Force -SkipPublisherCheck -Scope CurrentUser -Repository PSGallery + Install-Module -Name Pester -MaximumVersion 4.99 -Force -SkipPublisherCheck -Scope CurrentUser -Repository PSGallery } } }