Skip to content

Commit

Permalink
Upgrade to Pester 5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
yoannchaudet committed Apr 14, 2021
1 parent 9605130 commit cebb3b7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
7 changes: 2 additions & 5 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env pwsh
#Requires -Version 7.0 -Modules @{ ModuleName='Pester'; ModuleVersion='5.1.1' }
#Requires -Version 7.0 -Modules @{ ModuleName='Pester'; ModuleVersion='5.2' }

<#
.SYNOPSIS
Expand Down Expand Up @@ -29,19 +29,16 @@ $ErrorActionPreference = 'Stop'
# Switch task
switch ($Task) {
'Test' {
Write-Host "Set path to be = $(Join-Path $PSScriptRoot 'src')"

# Build Pester configuration
$pesterConfiguration = @{
Run = @{
Path = (Join-Path $PSScriptRoot 'src')
}
CodeCoverage = @{
Enabled = $true
Path = (Join-Path $PSScriptRoot 'src' '*.ps1')
}
Output = @{
Verbosity = 'Diagnostic'
Verbosity = 'Detailed'
}
}

Expand Down
19 changes: 16 additions & 3 deletions install-build-dependencies.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,22 @@ if ($buildScriptAst.ScriptRequirements) {
Scope = 'CurrentUser'
Force = $true
}
if ($_.Version) { $params['MinimumVersion'] = $_.Version }
elseif ($_.RequiredVersion) { $params['RequiredVersion'] = $_.RequiredVersion }
elseif ($_.MaximumVersion) { $params['MaximumVersion'] = $_.MaximumVersion }

# Pester 5.1 has a bug preventing the codecoverage from being properly computed
# See https://github.com/pester/Pester/pull/1807
# The fix will be in 5.2 which has not been released yet and since PowerShell does not support
# semantic versioning 2.0 (😱), we cannot rely on an alpha version in build.ps1
# Temporarily force the alpha version here:
if ('Pester' -eq $params["Name"]) {
$params['RequiredVersion'] = '5.2.0-alpha3'
$params['AllowPrerelease'] = $true
}

else {
if ($_.Version) { $params['MinimumVersion'] = $_.Version }
elseif ($_.RequiredVersion) { $params['RequiredVersion'] = $_.RequiredVersion }
elseif ($_.MaximumVersion) { $params['MaximumVersion'] = $_.MaximumVersion }
}

# Install the module
[PSCustomObject] $params | Format-Table
Expand Down

0 comments on commit cebb3b7

Please sign in to comment.