FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Fix get-help online test by adityapatwardhan · Pull Request #3051 · PowerShell/PowerShell · GitHub

Fix get-help online test - #3051

Merged
Dongbo Wang (daxian-dbw) merged 7 commits into
PowerShell:masterfrom
adityapatwardhan:HelpOnlineFix
Feb 2, 2017
Merged

Fix get-help online test#3051
Dongbo Wang (daxian-dbw) merged 7 commits into
PowerShell:masterfrom
adityapatwardhan:HelpOnlineFix

Conversation

Copy link
Copy Markdown
Member

Fix the get-help -online test so that when a default browser is not set,
the test does not fail.

Fix the get-help -online test so that when a default browser is not set,
the test does not fail.
{
{ throw $errorThrown } | Should Not Throw
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Two thoughts:

  1. This solution seems overly complex and difficult to parse. Can you simplify it and still retain the same behavior? Maybe use an else within the catch block?
  2. If you keep it this way then comments are needed to describe what you are doing and why

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Added code to check if default browser is set.


It "Get-Help get-process -online" -skip:$skipTest {

{ Get-Help get-process -online } | Should Not Throw

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Would it make more sense to check if the default browser is set? If it is, run the test; otherwise, skip it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Good idea. I have added the code similar to the product.


$skipTest = [System.Management.Automation.Platform]::IsIoT -or
[System.Management.Automation.Platform]::IsNanoServer
[System.Management.Automation.Platform]::IsNanoServer

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looks like unneeded formating.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Fixed.

Copy link
Copy Markdown
Member Author

Francisco Gamino (@Francisco-Gamino) Mike Richmond (@mirichmo)

Are you OK with the changes?

if($IsWindows)
{
$regKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice"
$progId = [Microsoft.Win32.Registry]::GetValue($regKey, "ProgId", $null)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

What about a try-catch here? This can potentially throw

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

if($browserKey)
{
$browserExe = $browserKey.GetValue($null)
if($browserExe -notmatch '.exe')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Hi Aditya Patwardhan (@adityapatwardhan). To get the default browser executable path you need to parse the output of $browserKey.GetValue($null). This would look something like this: $browserExe = (($browserKey.GetValue($null) -replace '"' ,"") -split " ")[0].

Also, you could potentially set $skipTest to $false by default which will simplify your logic to something like this:

$skipTest = $true
try
{
$regKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice"
$progId = [Microsoft.Win32.Registry]::GetValue($regKey, "ProgId", $null)
if($progId)
{
$browserKey = [Microsoft.Win32.Registry]::ClassesRoot.OpenSubKey("$progId\shell\open\command", $false)
if($browserKey)
{
$browserExe = (($browserKey.GetValue($null) -replace '"' ,"") -split " ")[0]
if($browserExe.EndsWith('.exe'))
{
$skipTest = $false
}
}
}
}
catch
{
# ignore the failure
}

Aditya Patwardhan (adityapatwardhan) Jan 30, 2017
edited
Loading

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Fixed. Francisco Gamino (@Francisco-Gamino) please have a look.

Copy link
Copy Markdown
Member

Francisco Gamino (@Francisco-Gamino) Do you have any additional comments?

Francisco Gamino (Francisco-Gamino) commented Jan 31, 2017
edited
Loading

Copy link
Copy Markdown
Contributor

Aditya Patwardhan (@adityapatwardhan) : You should probably squash your commits into one. Other than that, LGTM.

Copy link
Copy Markdown
Member Author

@PowerShell/powershell-maintainers This is ready for merge.

Copy link
Copy Markdown
Member

Chatted with Aditya Patwardhan (@adityapatwardhan) offline, and it looks like a bug in the default browser detection code because:

  • cmd /c start /B www.bing.com would open www.bing.com in IE
  • get-help -online gps works in Windows PowerShell on the same machine, but fails on PSv6

We need to fix this in product code. Francisco Gamino (@Francisco-Gamino): thought?

Copy link
Copy Markdown
Member Author

This is workaround due to #3079. This should be removed when #3079 is fixed.

Copy link
Copy Markdown
Member

Perhaps you should put a comment in the code to the effect that this is a workaround for #3079 .

This would help if someone is trying to understand the code.

Copy link
Copy Markdown
Member Author

Travis Plunk (@TravisEz13) Checks have passed. Ready for merge.

Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj/PowerShell that referenced this pull request Aug 6, 2026
Fix the "get-help -online" test using a workaround so that when a default browser is not set, the test does not fail.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL