From 8303a2b3fb1ff04adc974a68bcdfc53bfe51026c Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Wed, 1 Feb 2017 17:19:55 -0800 Subject: [PATCH] Fix get-help online test (#3051) Fix the "get-help -online" test using a workaround so that when a default browser is not set, the test does not fail. --- .../Help/HelpSystem.OnlineHelp.Tests.ps1 | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/test/powershell/engine/Help/HelpSystem.OnlineHelp.Tests.ps1 b/test/powershell/engine/Help/HelpSystem.OnlineHelp.Tests.ps1 index 9d8913919..77897052a 100644 --- a/test/powershell/engine/Help/HelpSystem.OnlineHelp.Tests.ps1 +++ b/test/powershell/engine/Help/HelpSystem.OnlineHelp.Tests.ps1 @@ -55,8 +55,39 @@ Describe 'Get-Help -Online opens the default web browser and navigates to the cm $skipTest = [System.Management.Automation.Platform]::IsIoT -or [System.Management.Automation.Platform]::IsNanoServer - It "Get-Help get-process -online" -skip:$skipTest { + # this code is a workaround for issue: https://github.com/PowerShell/PowerShell/issues/3079 + if((-not ($skipTest)) -and $IsWindows) + { + $skipTest = $true + $regKey = "HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice" + try + { + $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 " " + + if ($browserExe.count -ge 1) + { + if($browserExe[0] -match '.exe') + { + $skipTest = $false + } + } + } + } + } + catch + { + # We are not able to access Registry, skipping test. + } + } + + It "Get-Help get-process -online" -skip:$skipTest { { Get-Help get-process -online } | Should Not Throw } }