From 16baf8af703dadb7efe6869d2f5de1b915c285aa Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Fri, 17 May 2019 14:22:46 -0700 Subject: [PATCH 1/3] make sure we don't return null results fixes #9396 --- src/System.Management.Automation/engine/CommandSearcher.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Management.Automation/engine/CommandSearcher.cs b/src/System.Management.Automation/engine/CommandSearcher.cs index a703b2ec28c..002535f2da9 100644 --- a/src/System.Management.Automation/engine/CommandSearcher.cs +++ b/src/System.Management.Automation/engine/CommandSearcher.cs @@ -565,7 +565,7 @@ private Collection GetNextFromPathUsingWildcards(string command, out Pro } provider = null; - return null; + return new Collection(); } private static bool checkPath(string path, string commandName) From 763e29a25dc7731fc4497cd10de27540286dbc41 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Fri, 17 May 2019 14:37:00 -0700 Subject: [PATCH 2/3] Add tests to verify change --- test/powershell/engine/Basic/CommandDiscovery.Tests.ps1 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/powershell/engine/Basic/CommandDiscovery.Tests.ps1 b/test/powershell/engine/Basic/CommandDiscovery.Tests.ps1 index 030301477c2..8fd5a055b18 100644 --- a/test/powershell/engine/Basic/CommandDiscovery.Tests.ps1 +++ b/test/powershell/engine/Basic/CommandDiscovery.Tests.ps1 @@ -205,4 +205,10 @@ Describe "Command Discovery tests" -Tags "CI" { } } } + + Context "error cases" { + It 'Get-Command "less `"-PsPage %db?B of %DoesNotExist:`"" should throw Drive not found' { + {Get-Command -Name "less `"-PsPage %db?B of %DoesNotExist:`""} | Should -Throw -ErrorId 'DriveNotFound' -because "The drive 'DoesNotExist:' should not exist" + } + } } From b08335bf1f0f6cb2058948a09a41db6b2ac98e15 Mon Sep 17 00:00:00 2001 From: Travis Plunk Date: Mon, 20 May 2019 10:27:54 -0700 Subject: [PATCH 3/3] Update test/powershell/engine/Basic/CommandDiscovery.Tests.ps1 Co-Authored-By: Ilya --- test/powershell/engine/Basic/CommandDiscovery.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/engine/Basic/CommandDiscovery.Tests.ps1 b/test/powershell/engine/Basic/CommandDiscovery.Tests.ps1 index 8fd5a055b18..fa3e957e80b 100644 --- a/test/powershell/engine/Basic/CommandDiscovery.Tests.ps1 +++ b/test/powershell/engine/Basic/CommandDiscovery.Tests.ps1 @@ -208,7 +208,7 @@ Describe "Command Discovery tests" -Tags "CI" { Context "error cases" { It 'Get-Command "less `"-PsPage %db?B of %DoesNotExist:`"" should throw Drive not found' { - {Get-Command -Name "less `"-PsPage %db?B of %DoesNotExist:`""} | Should -Throw -ErrorId 'DriveNotFound' -because "The drive 'DoesNotExist:' should not exist" + {Get-Command -Name "less `"-PsPage %db?B of %DoesNotExist:`""} | Should -Throw -ErrorId 'DriveNotFound' -Because "The drive 'DoesNotExist:' should not exist" } } }