mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Get-help may return multiple instances of the same help file (#3410)
* Help was incorrectly returning multiple instances of the same help file if it existed under a culture path and the parent was in the search path as well * updated test to use generated help file rather than an actual one * Fixed test to have module in $pshome path and casing of en-US culture
This commit is contained in:
@@ -273,7 +273,11 @@ namespace System.Management.Automation
|
||||
Diagnostics.Assert(searchPaths != null,
|
||||
"HelpSystem returned an null search path");
|
||||
|
||||
searchPaths.Add(GetDefaultShellSearchPath());
|
||||
string defaultShellSearchPath = GetDefaultShellSearchPath();
|
||||
if (!searchPaths.Contains(defaultShellSearchPath))
|
||||
{
|
||||
searchPaths.Add(defaultShellSearchPath);
|
||||
}
|
||||
|
||||
return searchPaths;
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace System.Management.Automation
|
||||
string leafFileName = Path.GetFileName(file);
|
||||
string uniqueToDirectory = Path.Combine(directory, leafFileName);
|
||||
|
||||
if (!_uniqueMatches.Contains(uniqueToDirectory))
|
||||
if (!_result.Contains(path) && !_uniqueMatches.Contains(uniqueToDirectory))
|
||||
{
|
||||
_result.Add(path);
|
||||
_uniqueMatches[uniqueToDirectory] = true;
|
||||
|
||||
@@ -180,3 +180,24 @@ Describe "Validate that Get-Help returns provider-specific help" -Tags @('CI', '
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Validate about_help.txt under culture specific folder works" -Tags @('CI') {
|
||||
BeforeAll {
|
||||
$modulePath = "$pshome\Modules\Test"
|
||||
$null = New-Item -Path $modulePath\en-US -ItemType Directory -Force
|
||||
New-ModuleManifest -Path $modulePath\test.psd1 -RootModule test.psm1
|
||||
Set-Content -Path $modulePath\test.psm1 -Value "function foo{}"
|
||||
Set-Content -Path $modulePath\en-US\about_testhelp.help.txt -Value "Hello" -NoNewline
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
Remove-Item $modulePath -Recurse -Force
|
||||
}
|
||||
|
||||
It "Get-Help should return help text and not multiple HelpInfo objects when help is under `$pshome path" {
|
||||
|
||||
$help = Get-Help about_testhelp
|
||||
$help.count | Should Be 1
|
||||
$help | Should BeExactly "Hello"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user