mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Add support to ActionPreference.Break to break into debugger (#8205)
This commit is contained in:
@@ -1,6 +1,56 @@
|
||||
# Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
# Licensed under the MIT License.
|
||||
|
||||
Describe 'Basic debugger tests' -tag 'CI' {
|
||||
|
||||
BeforeAll {
|
||||
Register-DebuggerHandler
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
Unregister-DebuggerHandler
|
||||
}
|
||||
|
||||
Context 'The value of $? should be preserved when exiting the debugger' {
|
||||
BeforeAll {
|
||||
$testScript = {
|
||||
function Test-DollarQuestionMark {
|
||||
[CmdletBinding()]
|
||||
param()
|
||||
Get-Process -id ([int]::MaxValue)
|
||||
if (-not $?) {
|
||||
'The value of $? was preserved during debugging.'
|
||||
} else {
|
||||
'The value of $? was changed to $true during debugging.'
|
||||
}
|
||||
}
|
||||
$global:DollarQuestionMarkResults = Test-DollarQuestionMark -ErrorAction Break
|
||||
}
|
||||
|
||||
$global:results = @(Test-Debugger -ScriptBlock $testScript -CommandQueue '$?')
|
||||
}
|
||||
|
||||
AfterAll {
|
||||
Remove-Variable -Name DollarQuestionMarkResults -Scope Global -ErrorAction Ignore
|
||||
}
|
||||
|
||||
It 'Should show 2 debugger commands were invoked' {
|
||||
# One extra for the implicit 'c' command that keeps the debugger automation moving
|
||||
$results.Count | Should -Be 2
|
||||
}
|
||||
|
||||
It 'Should have $false output from the first $? command' {
|
||||
$results[0].Output | Should -BeOfType bool
|
||||
$results[0].Output | Should -Not -BeTrue
|
||||
}
|
||||
|
||||
It 'Should have string output showing that $? was preserved as $false by the debugger' {
|
||||
$global:DollarQuestionMarkResults | Should -BeOfType string
|
||||
$global:DollarQuestionMarkResults | Should -BeExactly 'The value of $? was preserved during debugging.'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Describe "Breakpoints when set should be hit" -tag "CI" {
|
||||
Context "Basic tests" {
|
||||
BeforeAll {
|
||||
|
||||
Reference in New Issue
Block a user