Repository navigation
Fixing get-help on Linux #1695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing get-help on Linux #1695
Changes from all commits
3ed7201
233e756
2b1dc87
135af20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -113,11 +113,31 @@ private void SearchForFiles() | |
| } | ||
| } | ||
|
|
||
| private string[] GetFiles(string path, string pattern) | ||
| { | ||
| #if UNIX | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think ideally we would have the help files named correctly, but this works for now. |
||
| // 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; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh. I see why your tests are failing. You need to add this to |
||
| }, | ||
|
|
||
| "frameworks": { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <HelpInfo xmlns="http://schemas.microsoft.com/powershell/help/2010/05"> | ||
| <HelpContentURI>http://go.microsoft.com/fwlink/?linkid=390782</HelpContentURI> | ||
| <SupportedUICultures> | ||
| <UICulture> | ||
| <UICultureName>en-US</UICultureName> | ||
| <UICultureVersion>5.0.7.0</UICultureVersion> | ||
| </UICulture> | ||
| </SupportedUICultures> | ||
| </HelpInfo> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| # | ||
| # Validates Get-Help for cmdlets in Microsoft.PowerShell.Core. | ||
|
|
||
| function RunTestCase | ||
| { | ||
| param ([string]$tag = "CI") | ||
|
|
||
| $moduleName = "Microsoft.PowerShell.Core" | ||
|
|
||
| if ($IsWindows) | ||
| { | ||
| if ($tag -eq "CI") | ||
| { | ||
| $helpContentPath = join-path $PSScriptRoot "HelpContent" | ||
| $helpFiles = @(Get-ChildItem "$helpContentPath\*" -ea SilentlyContinue) | ||
|
|
||
| if ($helpFiles.Count -eq 0) | ||
| { | ||
| throw "unable to find help content at '$helpContentPath'" | ||
| } | ||
| Update-Help -Module $moduleName -SourcePath $helpContentPath -Force -ErrorAction Stop -Verbose | ||
| } | ||
|
|
||
| else | ||
| { | ||
| Update-Help -Module $moduleName -Force -Verbose -ErrorAction Stop | ||
| } | ||
| } | ||
|
|
||
| $cmdlets = get-command -module $moduleName | ||
|
|
||
| $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 | ||
| } | ||
|
|
||
| if ($tag -eq "CI") | ||
| { | ||
| # For a CI test run, we are only interested in validating one cmdlet to ensure that | ||
| # get-help <cmdletName> works. | ||
| break | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Describe "Validate that get-help <cmdletName> works" -Tags "CI" { | ||
|
|
||
| RunTestCase -tag "CI" | ||
| } | ||
|
|
||
| Describe "Validate Get-Help for all cmdlets in 'Microsoft.PowerShell.Core'" -Tags "Feature" { | ||
|
|
||
| RunTestCase -tag "Feature" | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're welcome :)