diff --git a/build.ps1 b/build.ps1 index 2e1aa2e..60945d5 100644 --- a/build.ps1 +++ b/build.ps1 @@ -84,28 +84,18 @@ if ($Bootstrap) { ErrorAction = 'Stop' } - $importSucceeded = $false - try { - Invoke-PSDepend @psDependParameters - $importSucceeded = $true - Write-Verbose 'Successfully imported existing modules.' -Verbose - } catch { - Write-Verbose "Could not import all required modules: $_" -Verbose - Write-Verbose 'Attempting to install missing or outdated dependencies...' -Verbose - } + $psDependTestParameters = $psDependParameters.Clone() + $null = $psDependTestParameters.Remove('Import') + $psDependTestParameters['Test'] = $true + $psDependTestParameters['Quiet'] = $true - if (-not $importSucceeded) { - try { - Invoke-PSDepend @psDependParameters -Install - } catch { - Write-Error "Failed to install and import required dependencies: $_" - Write-Error 'This may be due to locked module files. Please restart the build environment or clear module locks.' - if ($_.Exception.InnerException) { - Write-Error "Inner exception: $($_.Exception.InnerException.Message)" - } - throw - } + if (-not (Invoke-PSDepend @psDependTestParameters)) { + $psDependInstallParameters = $psDependParameters.Clone() + $null = $psDependInstallParameters.Remove('Import') + Invoke-PSDepend @psDependInstallParameters -Install } + + Invoke-PSDepend @psDependParameters } else { if (-not (Get-Module -Name 'PSDepend' -ListAvailable)) { throw 'Missing dependencies. Please run with the "-Bootstrap" flag to install dependencies.' diff --git a/requirements.psd1 b/requirements.psd1 index e401e1c..0526ea7 100644 --- a/requirements.psd1 +++ b/requirements.psd1 @@ -6,7 +6,7 @@ Target = 'CurrentUser' } 'Pester' = @{ - Version = '5.7.1' + Version = '6.2.0' Parameters = @{ SkipPublisherCheck = $true } diff --git a/tests/Get-PlasterManifestPathForCulture.Tests.ps1 b/tests/Get-PlasterManifestPathForCulture.Tests.ps1 index 40be779..2938897 100644 --- a/tests/Get-PlasterManifestPathForCulture.Tests.ps1 +++ b/tests/Get-PlasterManifestPathForCulture.Tests.ps1 @@ -39,6 +39,7 @@ Describe 'Get-PlasterManifestPathForCulture' { It "falls back to invariant culture manifest if no specific match is found" { $culture = New-Object System.Globalization.CultureInfo("xx-XX") + Mock -CommandName 'Test-Path' -MockWith { $False } Mock -CommandName 'Test-Path' -MockWith { $False } -ParameterFilter { $Path -like "*en-US*" } Mock -CommandName 'Test-Path' -MockWith { $True } -ParameterFilter { $Path -like "*fr-FR*" } Mock -CommandName 'Test-Path' -MockWith { $True } -ParameterFilter { $Path -like "*plasterManifest.xml" } diff --git a/tests/Help.tests.ps1 b/tests/Help.tests.ps1 index c9fc3e0..56fdc79 100644 --- a/tests/Help.tests.ps1 +++ b/tests/Help.tests.ps1 @@ -80,7 +80,7 @@ Describe "Test help for <_.Name>" -ForEach $commands { ($commandHelp.Examples.Example.Remarks | Select-Object -First 1).Text | Should -Not -BeNullOrEmpty } - It "Help link <_> is valid" -ForEach $helpLinks { + It "Help link <_> is valid" -ForEach $helpLinks -AllowNullOrEmptyForEach { (Invoke-WebRequest -Uri $_ -UseBasicParsing).StatusCode | Should -Be '200' } @@ -115,7 +115,7 @@ Describe "Test help for <_.Name>" -ForEach $commands { } } - Context "Test <_> help parameter help for " -ForEach $helpParameterNames { + Context "Test <_> help parameter help for " -ForEach $helpParameterNames -AllowNullOrEmptyForEach { # Shouldn't find extra parameters in help. It "finds help parameter in code: <_>" {