Fixing get-help on Linux

This commit is contained in:
Francisco Gamino
2016-08-10 12:19:51 -07:00
parent 800382f019
commit 3ed7201e21
4 changed files with 55 additions and 3 deletions
@@ -113,11 +113,31 @@ namespace System.Management.Automation
}
}
private string[] GetFiles(string path, string pattern)
{
#if UNIX
// On Linux, file names are case sensitive, so we need to add
// extra logic to select the files that match the given pattern.
ArrayList result = new ArrayList();
string[] files = Directory.GetFiles(path);
foreach (string filePath in files)
{
if (filePath.IndexOf(pattern, StringComparison.OrdinalIgnoreCase) >= 0)
{
result.Add(filePath);
}
}
return (String[])result.ToArray(typeof(string));
#else
return Directory.GetFiles(path, pattern);
#endif
}
private void AddFiles(string muiDirectory, string directory, string pattern)
{
if (Directory.Exists(muiDirectory))
{
string[] files = Directory.GetFiles(muiDirectory, pattern);
string[] files = GetFiles(muiDirectory, pattern);
if (files == null)
return;
@@ -1489,7 +1489,7 @@ namespace System.Management.Automation.Help
fileStream.Read(firstTwoBytes, 0, 2);
// Check for Mark Zbikowski’s magic initials
// Check for Mark Zbikowski's magic initials
if (firstTwoBytes[0] == 'M' && firstTwoBytes[1] == 'Z')
{
throw new UpdatableHelpSystemException("HelpContentContainsInvalidFiles",
@@ -1628,6 +1628,11 @@ namespace System.Management.Automation.Help
/// <returns></returns>
internal static bool ShouldPromptToUpdateHelp()
{
#if UNIX
// TODO: This workaround needs to be removed once updatable help
// works on Linux.
return false;
#else
try
{
if (!Utils.IsAdministrator())
@@ -1641,6 +1646,7 @@ namespace System.Management.Automation.Help
{
return false;
}
#endif
}
#endregion
+2 -1
View File
@@ -55,7 +55,8 @@
"Microsoft.PowerShell.PSReadLine": "1.0.0-*",
"libmi": "1.0.0-alpha01",
"PSDesiredStateConfiguration": "1.0.0-alpha01",
"Microsoft.PowerShell.PackageManagement": "1.0.0-*"
"Microsoft.PowerShell.PackageManagement": "1.0.0-*",
"PowerShellHelpFiles": "1.0.0-alpha01"
},
"frameworks": {
@@ -0,0 +1,25 @@
Describe 'Basic help system tests' -Tags "CI" {
Context "Validate help content for cmdlets in Microsof.PowerShell.Core" {
$cmdlets = get-command -module "Microsoft.PowerShell.Core"
$cmdletsToSkip = @(
"Get-PSHostProcessInfo",
"Out-Default",
"Register-ArgumentCompleter"
)
foreach ($cmdletName in $cmdlets)
{
if ($cmdletsToSkip -notcontains $cmdletName)
{
It "Validate -Description and -Examples sections in help content. Run 'Get-help -name $cmdletName'" {
$help = get-help -name $cmdletName
$help.Description | Out-String | Should Match $cmdletName
$help.Examples | Out-String | Should Match $cmdletName
}
}
}
}
}