From 6e5daaa42d00091e316915785480c1c05308fbed Mon Sep 17 00:00:00 2001 From: Ilya Date: Thu, 28 Nov 2019 12:48:43 +0500 Subject: [PATCH 1/4] Fix regression in Get-PSCallStack --- .../engine/TypeTable_Types_Ps1Xml.cs | 4 ++-- .../Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/System.Management.Automation/engine/TypeTable_Types_Ps1Xml.cs b/src/System.Management.Automation/engine/TypeTable_Types_Ps1Xml.cs index be3bf668893..caec473485e 100644 --- a/src/System.Management.Automation/engine/TypeTable_Types_Ps1Xml.cs +++ b/src/System.Management.Automation/engine/TypeTable_Types_Ps1Xml.cs @@ -6058,7 +6058,7 @@ private void Process_Types_Ps1Xml(string filePath, ConcurrentBag errors) { if ($argumentsBuilder.Length -gt 1) { - $argumentsBuilder.Append(string.Empty, string.Empty); + $argumentsBuilder.Append("", ""); } $argumentsBuilder.Append($entry.Key).Append(""="") @@ -6073,7 +6073,7 @@ private void Process_Types_Ps1Xml(string filePath, ConcurrentBag errors) { if ($argumentsBuilder.Length -gt 1) { - $argumentsBuilder.Append(string.Empty, string.Empty) + $argumentsBuilder.Append("", "") } if ($arg) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 index be5aaca1b1e..0c0d8b4e09f 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 @@ -49,17 +49,20 @@ Describe "Get-PSCallStack DRT Unit Tests" -Tags "CI" { $results[0].ScriptName | Should -Be $scriptFilePath $results[0].ScriptLineNumber | Should -Be 27 $results[0].InvocationInfo.ScriptLineNumber | Should -Be 9 + $results[0].Location | Should -Match $scriptFileName $results[1].Command | Should -BeExactly "foo" $results[1].ScriptName | Should -Be $scriptFilePath $results[1].ScriptLineNumber | Should -Be 9 $results[1].InvocationInfo.ScriptLineNumber | Should -Be 32 + $results[1].Location | Should -Match $scriptFileName #InvocationInfo.ScriptLineNumber: Gets the line number of the script that contains the command $results[2].Command | Should -Be $scriptFileName $results[2].ScriptName | Should -Be $scriptFilePath $results[2].ScriptLineNumber | Should -Be 32 $results[2].InvocationInfo.ScriptLineNumber | Should -Be 46 + $results[2].Location | Should -Match $scriptFileName } It "Verify that the script block of a trap statement shows up on the call stack" { @@ -86,4 +89,8 @@ Describe "Get-PSCallStack DRT Unit Tests" -Tags "CI" { $results[1].ScriptLineNumber | Should -Be 7 $results[1].InvocationInfo.ScriptLineNumber | Should -Be 77 } + + It "Get-PSCallStack returns Arguments" { + & { (Get-PSCallStack)[0].Arguments } 'foo' | Should -Match 'foo' + } } From eb672c12a2983344a80bffb873c907fd0a94fc8d Mon Sep 17 00:00:00 2001 From: Ilya Date: Thu, 28 Nov 2019 13:43:34 +0500 Subject: [PATCH 2/4] Fix test --- .../Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 index 0c0d8b4e09f..f1b90396e12 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 @@ -82,7 +82,7 @@ Describe "Get-PSCallStack DRT Unit Tests" -Tags "CI" { $results[0].Command | Should -Be $scriptFileName $results[0].ScriptName | Should -Be $scriptFilePath $results[0].ScriptLineNumber | Should -Be 3 - $results[0].InvocationInfo.ScriptLineNumber | Should -Be 77 + $results[0].InvocationInfo.ScriptLineNumber | Should -Be 80 $results[1].Command | Should -Be $scriptFileName $results[1].ScriptName | Should -Be $scriptFilePath From 27da3d2be3076f04f77c51936fe1c7579e7eb27a Mon Sep 17 00:00:00 2001 From: Ilya Date: Thu, 28 Nov 2019 14:07:24 +0500 Subject: [PATCH 3/4] Fix test 2 --- .../Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 index f1b90396e12..9a0d46b7d74 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 @@ -87,7 +87,7 @@ Describe "Get-PSCallStack DRT Unit Tests" -Tags "CI" { $results[1].Command | Should -Be $scriptFileName $results[1].ScriptName | Should -Be $scriptFilePath $results[1].ScriptLineNumber | Should -Be 7 - $results[1].InvocationInfo.ScriptLineNumber | Should -Be 77 + $results[1].InvocationInfo.ScriptLineNumber | Should -Be 80 } It "Get-PSCallStack returns Arguments" { From f7b914d361e8f019755d8895b2d0aa866eb776aa Mon Sep 17 00:00:00 2001 From: Ilya Date: Thu, 28 Nov 2019 20:07:22 +0500 Subject: [PATCH 4/4] Add more tests --- .../Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 index 9a0d46b7d74..97df34580bc 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Get-PSCallStack.Tests.ps1 @@ -91,6 +91,8 @@ Describe "Get-PSCallStack DRT Unit Tests" -Tags "CI" { } It "Get-PSCallStack returns Arguments" { - & { (Get-PSCallStack)[0].Arguments } 'foo' | Should -Match 'foo' + & { (Get-PSCallStack)[0].Arguments } 'foo' | Should -Match 'foo' + & { param ($x) (Get-PSCallStack)[0].Arguments } 'foo' | Should -Match 'foo' + & { (Get-PSCallStack)[0].Arguments } 'foo' 'bar' | Should -Match 'foo, bar' } }