@@ -11,6 +11,39 @@ defmodule Sentry.EventTest do
1111 end
1212 end
1313
14+ def get_stacktrace_frames_for_elixir ( ) do
15+ cond do
16+ Version . match? ( System . version , "< 1.4.0" ) ->
17+ [
18+ % { filename: nil , function: "Sentry.Event.not_a_function/3" , lineno: nil , module: Sentry.Event , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { "arg0" => "1" , "arg1" => "2" , "arg2" => "3" } } ,
19+ % { filename: "test/event_test.exs" , function: "Sentry.EventTest.event_generated_by_exception/1" , lineno: 8 , module: Sentry.EventTest , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { } } ,
20+ % { filename: "test/event_test.exs" , function: "Sentry.EventTest.\" test parses error exception\" /1" , lineno: 48 , module: Sentry.EventTest , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { } } ,
21+ % { filename: "lib/ex_unit/runner.ex" , function: "ExUnit.Runner.exec_test/1" , lineno: 296 , module: ExUnit.Runner , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { } } ,
22+ % { filename: "timer.erl" , function: ":timer.tc/1" , lineno: 166 , module: :timer , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { } } ,
23+ % { filename: "lib/ex_unit/runner.ex" , function: "anonymous fn/3 in ExUnit.Runner.spawn_test/3" , lineno: 246 , module: ExUnit.Runner , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { } } ,
24+ ]
25+ Version . match? ( System . version , "< 1.5.0" ) ->
26+ [
27+ % { filename: nil , function: "Sentry.Event.not_a_function/3" , lineno: nil , module: Sentry.Event , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { "arg0" => "1" , "arg1" => "2" , "arg2" => "3" } } ,
28+ % { filename: "test/event_test.exs" , function: "Sentry.EventTest.event_generated_by_exception/1" , lineno: 8 , module: Sentry.EventTest , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { } } ,
29+ % { filename: "test/event_test.exs" , function: "Sentry.EventTest.\" test parses error exception\" /1" , lineno: 48 , module: Sentry.EventTest , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { } } ,
30+ % { filename: "lib/ex_unit/runner.ex" , function: "ExUnit.Runner.exec_test/1" , lineno: 302 , module: ExUnit.Runner , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { } } ,
31+ % { filename: "timer.erl" , function: ":timer.tc/1" , lineno: 166 , module: :timer , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { } } ,
32+ % { filename: "lib/ex_unit/runner.ex" , function: "anonymous fn/3 in ExUnit.Runner.spawn_test/3" , lineno: 250 , module: ExUnit.Runner , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { } } ,
33+ ]
34+ Version . match? ( System . version , ">= 1.5.0" ) ->
35+ [
36+ % { filename: nil , function: "Sentry.Event.not_a_function/3" , lineno: nil , module: Sentry.Event , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { "arg0" => "1" , "arg1" => "2" , "arg2" => "3" } } ,
37+ % { filename: "test/event_test.exs" , function: "Sentry.EventTest.event_generated_by_exception/1" , lineno: 8 , module: Sentry.EventTest , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { } } ,
38+ % { filename: "test/event_test.exs" , function: "Sentry.EventTest.\" test parses error exception\" /1" , lineno: 48 , module: Sentry.EventTest , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { } } ,
39+ % { filename: "lib/ex_unit/runner.ex" , function: "ExUnit.Runner.exec_test/1" , lineno: 292 , module: ExUnit.Runner , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { } } ,
40+ % { filename: "timer.erl" , function: ":timer.tc/1" , lineno: 166 , module: :timer , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { } } ,
41+ % { filename: "lib/ex_unit/runner.ex" , function: "anonymous fn/3 in ExUnit.Runner.spawn_test/3" , lineno: 240 , module: ExUnit.Runner , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { } } ,
42+ ]
43+ end
44+ end
45+
46+
1447 test "parses error exception" do
1548 event = event_generated_by_exception ( )
1649
@@ -26,13 +59,7 @@ defmodule Sentry.EventTest do
2659 assert event . message == "(UndefinedFunctionError) function Sentry.Event.not_a_function/3 is undefined or private"
2760 assert is_binary ( event . server_name )
2861 assert event . stacktrace == % {
29- frames: Enum . reverse ( [
30- % { filename: nil , function: "Sentry.Event.not_a_function/3" , lineno: nil , module: Sentry.Event , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { "arg0" => "1" , "arg1" => "2" , "arg2" => "3" } } ,
31- % { filename: "test/event_test.exs" , function: "Sentry.EventTest.event_generated_by_exception/1" , lineno: 8 , module: Sentry.EventTest , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { } } ,
32- % { filename: "test/event_test.exs" , function: "Sentry.EventTest.\" test parses error exception\" /1" , lineno: 15 , module: Sentry.EventTest , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { } } ,
33- % { filename: "lib/ex_unit/runner.ex" , function: "ExUnit.Runner.exec_test/1" , lineno: 302 , module: ExUnit.Runner , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { } } ,
34- % { filename: "timer.erl" , function: ":timer.tc/1" , lineno: 166 , module: :timer , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { } } ,
35- % { filename: "lib/ex_unit/runner.ex" , function: "anonymous fn/3 in ExUnit.Runner.spawn_test/3" , lineno: 250 , module: ExUnit.Runner , context_line: nil , post_context: [ ] , pre_context: [ ] , in_app: false , vars: % { } } ] )
62+ frames: get_stacktrace_frames_for_elixir ( ) |> Enum . reverse
3663 }
3764 assert event . tags == % { }
3865 assert event . timestamp =~ ~r/ \d {4}-\d {2}-\d {2}T\d {2}:\d {2}:\d {2}/
0 commit comments