-
-
Notifications
You must be signed in to change notification settings - Fork 2
add out-sentry integration-test script #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
52bf885
fadfa1a
5fd0739
9980757
c5963aa
362b42a
374eaa7
ce4e234
d1d60ab
98f1792
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Set-StrictMode -Version latest | ||
$ErrorActionPreference = 'Stop' | ||
$PSNativeCommandUseErrorActionPreference = $true | ||
|
||
Import-Module ../modules/Sentry/Sentry.psd1 | ||
. ./utils.ps1 | ||
|
||
$events = [System.Collections.Generic.List[Sentry.SentryEvent]]::new(); | ||
$transport = [RecordingTransport]::new() | ||
StartSentryForEventTests ([ref] $events) ([ref] $transport) | ||
|
||
try | ||
{ | ||
funcA 'throw' 'error' | ||
} | ||
catch | ||
{ | ||
$_ | Out-Sentry | Out-Null | ||
} | ||
|
||
$events[0].SentryThreads.Stacktrace.Frames | ForEach-Object { | ||
'----------------' | Out-String | ||
$frame = $_ | ||
$properties = $frame | Get-Member -MemberType Properties | Select-Object -ExpandProperty Name | ||
foreach ($prop in $properties) | ||
{ | ||
$value = $frame.$prop | Out-String -Width 500 | ||
"$($prop):$value" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
BeforeAll { | ||
$integrationTestScript = "$PSScriptRoot$([IO.Path]::DirectorySeparatorChar)integration-test-script.ps1" | ||
$integrationTestScriptContent = Get-Content -Raw $integrationTestScript | ||
|
||
$checkOutput = { | ||
|
||
param([string[]] $output, [string[]] $expected) | ||
# Remove empty lines | ||
$output = $output | Where-Object { $_ -ne '' } | ||
|
||
# Print out so that we can compare the whole output if the test fails | ||
$output | Write-Host | ||
|
||
for ($i = 0; $i -lt $expected.Count -and $i -lt $output.Count; $i++) | ||
{ | ||
$output[$i] | Should -Be $expected[$i] -Because "Output line $i" | ||
} | ||
$output.Count | Should -Be $expected.Count | ||
} | ||
} | ||
|
||
Describe 'Out-Sentry captures expected stack traces for command input' { | ||
BeforeEach { | ||
Push-Location "$PSScriptRoot" | ||
$expected = @( | ||
|
||
'----------------' | ||
'AbsolutePath:<No file>' | ||
'AddressMode:' | ||
'ColumnNumber:' | ||
'ContextLine:' | ||
'FileName:' | ||
'FramesOmitted:' | ||
'Function:<ScriptBlock>' | ||
'FunctionId:' | ||
'ImageAddress:' | ||
'InApp:True' | ||
'InstructionAddress:' | ||
'LineNumber:1' | ||
'Module:' | ||
'Package:' | ||
'Platform:' | ||
'PostContext:' | ||
'PreContext:' | ||
'SymbolAddress:' | ||
'Vars:' | ||
'----------------' | ||
'AbsolutePath:<No file>' | ||
'AddressMode:' | ||
'ColumnNumber:' | ||
'ContextLine:' | ||
'FileName:' | ||
'FramesOmitted:' | ||
'Function:<ScriptBlock>' | ||
'FunctionId:' | ||
'ImageAddress:' | ||
'InApp:True' | ||
'InstructionAddress:' | ||
'LineNumber:14' | ||
'Module:' | ||
'Package:' | ||
'Platform:' | ||
'PostContext:' | ||
'PreContext:' | ||
'SymbolAddress:' | ||
'Vars:' | ||
'----------------' | ||
'AbsolutePath:' | ||
'AddressMode:' | ||
'ColumnNumber:5' | ||
"ContextLine: funcA 'throw' 'error'" | ||
'FileName:' | ||
'FramesOmitted:' | ||
'Function:' | ||
'FunctionId:' | ||
'ImageAddress:' | ||
'InApp:True' | ||
'InstructionAddress:' | ||
'LineNumber:14' | ||
'Module:' | ||
'Package:' | ||
'Platform:' | ||
'PostContext:' | ||
'PreContext:' | ||
'SymbolAddress:' | ||
'Vars:' | ||
) | ||
|
||
} | ||
|
||
AfterEach { | ||
Pop-Location | ||
} | ||
|
||
It 'Windows PowerShell' -Skip:($env:OS -ne 'Windows_NT') { | ||
$output = powershell.exe -Command "& {$integrationTestScriptContent}" -ErrorAction Continue | ||
$checkOutput.Invoke($output, $expected) | ||
} | ||
|
||
It 'PowerShell' { | ||
$output = pwsh -Command "& {$integrationTestScriptContent}" -ErrorAction Continue | ||
$checkOutput.Invoke($output, $expected) | ||
} | ||
} | ||
|
||
Describe 'Out-Sentry captures expected stack traces for file input' { | ||
BeforeEach { | ||
Push-Location "$PSScriptRoot" | ||
$expected = @( | ||
|
||
'----------------' | ||
'AbsolutePath:<No file>' | ||
'AddressMode:' | ||
'ColumnNumber:' | ||
'ContextLine:' | ||
'FileName:' | ||
'FramesOmitted:' | ||
'Function:<ScriptBlock>' | ||
'FunctionId:' | ||
'ImageAddress:' | ||
'InApp:True' | ||
'InstructionAddress:' | ||
'LineNumber:1' | ||
'Module:' | ||
'Package:' | ||
'Platform:' | ||
'PostContext:' | ||
'PreContext:' | ||
'SymbolAddress:' | ||
'Vars:' | ||
'----------------' | ||
"AbsolutePath:$integrationTestScript" | ||
'AddressMode:' | ||
'ColumnNumber:5' | ||
"ContextLine: funcA 'throw' 'error'" | ||
'FileName:' | ||
'FramesOmitted:' | ||
'Function:<ScriptBlock>' | ||
'FunctionId:' | ||
'ImageAddress:' | ||
'InApp:True' | ||
'InstructionAddress:' | ||
'LineNumber:14' | ||
'Module:' | ||
'Package:' | ||
'Platform:' | ||
'PostContext:}' | ||
'catch' | ||
'{' | ||
' $_ | Out-Sentry | Out-Null' | ||
'}' | ||
'PreContext:$transport = [RecordingTransport]::new()' | ||
'StartSentryForEventTests ([ref] $events) ([ref] $transport)' | ||
'try' | ||
'{' | ||
'SymbolAddress:' | ||
'Vars:' | ||
) | ||
} | ||
|
||
AfterEach { | ||
Pop-Location | ||
} | ||
|
||
It 'Windows PowerShell' -Skip:($env:OS -ne 'Windows_NT') { | ||
$PSNativeCommandUseErrorActionPreference = $false | ||
$output = powershell.exe $integrationTestScript | ||
$checkOutput.Invoke($output, $expected) | ||
} | ||
|
||
It 'PowerShell' { | ||
$PSNativeCommandUseErrorActionPreference = $false | ||
$output = pwsh -Command $integrationTestScript | ||
$checkOutput.Invoke($output, $expected) | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.