mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Guard against null or blank path components when adding to module path (#19922)
This commit is contained in:
@@ -247,3 +247,21 @@ Describe "ModuleIntrinsics.GetPSModulePath API tests" -tag @('CI', 'RequireAdmin
|
||||
$currentModulePathElements | Should -Contain $mPath
|
||||
}
|
||||
}
|
||||
|
||||
Describe 'ModuleIntrinsics.GetModulePath environment interaction' -tag @('CI') {
|
||||
|
||||
It "GetModulePath does not crash when MyDocuments special folder is empty" {
|
||||
try {
|
||||
[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('SetMyDocumentsSpecialFolderToBlank', $true)
|
||||
[System.Management.Automation.ModuleIntrinsics]::GetModulePath($null, $null, $null)
|
||||
}
|
||||
finally {
|
||||
[System.Management.Automation.Internal.InternalTestHooks]::SetTestHook('SetMyDocumentsSpecialFolderToBlank', $false)
|
||||
}
|
||||
}
|
||||
|
||||
It "GetModulePath does not crash when MyDocuments special folder is not empty" {
|
||||
[System.Management.Automation.ModuleIntrinsics]::GetModulePath($null, $null, $null)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user