mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Move Set-StrictMode to outer scriptblock for ErrorView (#11381)
This commit is contained in:
+1
-1
@@ -991,9 +991,9 @@ namespace System.Management.Automation.Runspaces
|
||||
}
|
||||
")
|
||||
.AddScriptBlockExpressionBinding(@"
|
||||
Set-StrictMode -Off
|
||||
|
||||
function Get-ConciseViewPositionMessage {
|
||||
Set-StrictMode -Off
|
||||
|
||||
$resetColor = ''
|
||||
if ($Host.UI.SupportsVirtualTerminal -and !(Test-Path env:__SuppressAnsiEscapeSequences)) {
|
||||
|
||||
@@ -63,4 +63,23 @@ Describe 'Tests for $ErrorView' -Tag CI {
|
||||
$e | Out-String | Should -Not -BeLike '*pester*'
|
||||
}
|
||||
}
|
||||
|
||||
Context 'NormalView tests' {
|
||||
|
||||
It 'Error shows up when using strict mode' {
|
||||
try {
|
||||
$ErrorView = 'NormalView'
|
||||
Set-StrictMode -Version 2
|
||||
throw 'Oops!'
|
||||
}
|
||||
catch {
|
||||
$e = $_ | Out-String
|
||||
}
|
||||
finally {
|
||||
Set-StrictMode -Off
|
||||
}
|
||||
|
||||
$e | Should -BeLike '*Oops!*'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user