11BeforeAll {
22 . " $PSScriptRoot /utils.ps1"
3+ . " $PSScriptRoot /throwing.ps1"
34 $events = [System.Collections.Generic.List [Sentry.SentryEvent ]]::new();
45 $transport = [RecordingTransport ]::new()
56 StartSentryForEventTests ([ref ] $events ) ([ref ] $transport )
67
8+ function ContextLines ($start , $lines , $path = $null )
9+ {
10+ if ($null -eq $path )
11+ {
12+ $path = " $PSScriptRoot /throwing.ps1"
13+ }
14+
15+ Get-Content $path | Select-Object - Skip ($start - 1 ) - First $lines
16+ }
17+
718 $checkFrame = {
819 param ([Sentry.SentryStackFrame ] $frame , [string ] $funcName , [int ] $funcLine )
920 $frame.Function | Should - Be $funcName
10- $frame.AbsolutePath | Should - Be (Join-Path $PSScriptRoot ' utils .ps1' )
21+ $frame.AbsolutePath | Should - Be (Join-Path $PSScriptRoot ' throwing .ps1' )
1122 $frame.LineNumber | Should - BeGreaterThan 0
1223 $frame.InApp | Should - Be $true
1324 $frame.PreContext | Should - Be (ContextLines - Start ($funcLine - 5 ) - Lines 5 )
@@ -28,26 +39,26 @@ BeforeAll {
2839
2940 if ($event.SentryExceptions [1 ].Type -eq ' Write-Error' )
3041 {
31- $checkFrame.Invoke ((GetListItem $frames -1 ), ' funcB' , 46 )
42+ $checkFrame.Invoke ((GetListItem $frames -1 ), ' funcB' , 18 )
3243 $event.SentryExceptions [0 ].Type | Should - Be ' Microsoft.PowerShell.Commands.WriteErrorException'
3344 $event.SentryExceptions [0 ].Module | Should -Match ' Microsoft.PowerShell.Commands.Utility'
3445 }
3546 else
3647 {
3748 if ($event.SentryExceptions [1 ].Type -eq ' error' )
3849 {
39- $checkFrame.Invoke ((GetListItem $frames -1 ), ' funcB' , 45 )
50+ $checkFrame.Invoke ((GetListItem $frames -1 ), ' funcB' , 17 )
4051 $ (GetListItem $frames -1 ).ColumnNumber | Should - BeGreaterThan 0
4152 }
4253 else
4354 {
44- $checkFrame.Invoke ((GetListItem $frames -1 ), ' funcB' , 52 )
55+ $checkFrame.Invoke ((GetListItem $frames -1 ), ' funcB' , 24 )
4556 }
4657 $event.SentryExceptions [0 ].Type | Should - Be ' System.Management.Automation.RuntimeException'
4758 $event.SentryExceptions [0 ].Module | Should -Match ' System.Management.Automation'
4859 }
4960
50- $checkFrame.Invoke ((GetListItem $frames -2 ), ' funcA' , 35 )
61+ $checkFrame.Invoke ((GetListItem $frames -2 ), ' funcA' , 7 )
5162
5263 $event.SentryExceptions [0 ].Value | Should - Be ' error'
5364 if ($event.SentryExceptions [1 ].Type -eq ' error,funcB' )
@@ -88,8 +99,8 @@ Describe 'Out-Sentry' {
8899 $event.SentryThreads.Count | Should - Be 2
89100 [Sentry.SentryStackFrame []] $frames = $event.SentryThreads [0 ].Stacktrace.Frames
90101 $frames.Count | Should - BeGreaterThan 0
91- $checkFrame.Invoke ((GetListItem $frames -1 ), ' funcB' , 47 )
92- $checkFrame.Invoke ((GetListItem $frames -2 ), ' funcA' , 35 )
102+ $checkFrame.Invoke ((GetListItem $frames -1 ), ' funcB' , 19 )
103+ $checkFrame.Invoke ((GetListItem $frames -2 ), ' funcA' , 7 )
93104
94105 # A module-based frame should be in-app=false
95106 $frames | Where-Object - Property Module | Select-Object - First 1 - ExpandProperty ' InApp' | Should - Be $false
0 commit comments