8000 Get-Help should find help files under $pshome by chunqingchen · Pull Request #3528 · PowerShell/PowerShell · GitHub
[go: up one dir, main page]

Skip to content

Get-Help should find help files under $pshome #3528

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

Merged
merged 2 commits into from
May 1, 2017
Merged

Get-Help should find help files under $pshome #3528

merged 2 commits into from
May 1, 2017

Conversation

chunqingchen
Copy link
Contributor
@chunqingchen chunqingchen commented Apr 11, 2017

Relevant issue: #2653 #2649

Steps to reproduce

get-help about*
Expected behavior

get-help should be able to find the latest help files under $pshome

Actual behavior

get-help only get the files from C:\Windows\System32\WindowsPowerShell\v1.0

Environment data

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.15016.1000
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.15016.1000
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


try
{
New-Item -ItemType File -Path "$PSHOME\en-US\$helpFile" -Value "about_test" -ErrorAction SilentlyContinue
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we use SilentlyContinue we do not need to use Test-Path.
We can move New-Item's in BeforeAll:

BeforeAll {
    $helpFile = "about_testCase.help.txt" 
    New-Item -ItemType Directory -Path "$PSHOME\en-US" -ErrorAction SilentlyContinue
    New-Item -ItemType File -Path "$PSHOME\en-US\$helpFile" -Value "about_test" -ErrorAction SilentlyContinue
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closed.

}
finally
{
Remove-Item "$PSHOME\en-US\$helpFile" -Force -ErrorAction SilentlyContinue
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move it to AfterAll.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closed.

Remove-Item "$PSHOME\en-US\$helpFile" -Force -ErrorAction SilentlyContinue
}
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You missed "}".

@@ -199,5 +219,6 @@ Describe "Validate about_help.txt under culture specific folder works" -Tags @('
$help = Get-Help about_testhelp
$help.count | Should Be 1
$help | Should BeExactly "Hello"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove the extra line.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closed.

{
New-Item -ItemType File -Path "$PSHOME\en-US\$helpFile" -Value "about_test" -ErrorAction SilentlyContinue
$helpContent = Get-Help about_testCase
$helpContent | Should Not Be $null
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we verify the exact value instead of $null?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be:

$helpContent | Should Not BeNullOrEmpty


Describe "Validate about_help.txt under culture specific folder works" -Tags @('CI') {
BeforeAll {
$modulePath = "$pshome\Modules\Test"
Copy link
Collaborator
@iSazonov iSazonov Apr 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please clarify - is "Module" hardcoded for searching help files? And do this folder always exist? Maybe we should New-Item for it too?

@TravisEz13
Copy link
Member

I restarted MacOS because it appeared to have an issue downloading dotnet cli

@SteveL-MSFT
Copy link
Member

@chunqingchen please verify this also addresses #2649

$helpFile = "about_testCase.help.txt"
if (!(Test-Path $PSHOME\en-US))
{
New-Item -ItemType Directory -Path "$PSHOME\en-US" -ErrorAction SilentlyContinue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be as follows to avoid output on console.

$null = New-Item -ItemType Directory -Path "$PSHOME\en-US" -ErrorAction SilentlyContinue 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved


try
{
New-Item -ItemType File -Path "$PSHOME\en-US\$helpFile" -Value "about_test" -ErrorAction SilentlyContinue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

{
New-Item -ItemType File -Path "$PSHOME\en-US\$helpFile" -Value "about_test" -ErrorAction SilentlyContinue
$helpContent = Get-Help about_testCase
$helpContent | Should Not Be $null
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be:

$helpContent | Should Not BeNullOrEmpty

@chunqingchen
Copy link
Contributor Author

@adityapatwardhan your comments are resolved

Describe "Get-Help should find help info within help files" -Tags @('CI', 'RequireAdminOnWindows') {
It "Get-Help should find help files under pshome" {
$helpFile = "about_testCase.help.txt"
if (!(Test-Path $PSHOME\en-US))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this test case only meant to run on en-US? If it is, then you should skip it for non-English runs. Otherwise, please use (get-uiculture).Name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

{
$null = New-Item -ItemType File -Path "$PSHOME\en-US\$helpFile" -Value "about_test" -ErrorAction SilentlyContinue
$helpContent = Get-Help about_testCase
$helpContent | Should Not Be $null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check should probably be $helpContent | Should Match "about_test"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolved

@chunqingchen
Copy link
Contributor Author

@Francisco-Gamino thanks, your comments are resolved

It "Get-Help should find help files under pshome" {
$helpFile = "about_testCase.help.txt"
$culture = (Get-Culture).Name
if (!(Test-Path $PSHOME\en-US))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, does this tests run on Linux? If it does, then please use Join-Path instead of "$path\value"
E.g.,
$helpContentPath = join-path $PSHOME $culture
if (-not (test-path $helpContentPath))
{
}

@chunqingchen
Copy link
Contributor Author

@Francisco-Gamino thanks, your comment is resolved !

@mirichmo
Copy link
Member

@Francisco-Gamino && @adityapatwardhan Do you guys have any more concerns or is this ready for merge?

@SteveL-MSFT SteveL-MSFT added this to the 6.0.0-beta1 milestone May 1, 2017
Copy link
Contributor
@Francisco-Gamino Francisco-Gamino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update this path $modulePath\en-US to $modulePath(get-uiculture).name. Other than that, it looks good. Thanks.

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This path should be $modulePath(get-culture).name

@adityapatwardhan
Copy link
Member

@chunqingchen Changes approved.

@chunqingchen
Copy link
Contributor Author

@Francisco-Gamino en-us is replaced with culture
@mirichmo please merge the change.

@mirichmo mirichmo merged commit 5a82b10 into PowerShell:master May 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants
0