mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Fix regression in Get-PSCallStack (#11210)
This commit is contained in:
@@ -6058,7 +6058,7 @@ namespace System.Management.Automation.Runspaces
|
||||
{
|
||||
if ($argumentsBuilder.Length -gt 1)
|
||||
{
|
||||
$argumentsBuilder.Append(string.Empty, string.Empty);
|
||||
$argumentsBuilder.Append("", "");
|
||||
}
|
||||
|
||||
$argumentsBuilder.Append($entry.Key).Append(""="")
|
||||
@@ -6073,7 +6073,7 @@ namespace System.Management.Automation.Runspaces
|
||||
{
|
||||
if ($argumentsBuilder.Length -gt 1)
|
||||
{
|
||||
$argumentsBuilder.Append(string.Empty, string.Empty)
|
||||
$argumentsBuilder.Append("", "")
|
||||
}
|
||||
|
||||
if ($arg)
|
||||
|
||||
@@ -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" {
|
||||
@@ -79,11 +82,17 @@ 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
|
||||
$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" {
|
||||
& { (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'
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user