Skip to content

Commit 6dc2ba1

Browse files
committed
Fix tests
1 parent 207b8fd commit 6dc2ba1

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

test/error_tracker_test.exs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,25 +32,17 @@ defmodule ErrorTrackerTest do
3232
test "reports badarith errors" do
3333
string_var = to_string(1)
3434

35-
# We set the otp_app to `nil` because the error is not reported by an OTP
36-
# application but by this script, so the last line of the stacktrace is not
37-
# the correct one if we leave the right value.
38-
Application.put_env(:error_tracker, :otp_app, nil)
39-
on_exit(fn -> Application.put_env(:error_tracker, :otp_app, :error_tracker) end)
40-
41-
%Occurrence{error: error = %Error{}} =
35+
%Occurrence{error: error = %Error{}, stacktrace: %{lines: [last_line | _]}} =
4236
report_error(fn -> 1 + string_var end)
4337

4438
assert error.kind == to_string(ArithmeticError)
4539
assert error.reason == "bad argument in arithmetic expression"
4640

47-
# Elixir 1.17.0 reports these errors differently than previous versions
48-
if Version.compare(System.version(), "1.17.0") == :lt do
49-
assert error.source_line =~ @relative_file_path
50-
else
51-
assert error.source_function == "erlang.+/2"
52-
assert error.source_line == "(nofile)"
53-
end
41+
assert last_line.module == "erlang"
42+
assert last_line.function == "+"
43+
assert last_line.arity == 2
44+
refute last_line.file
45+
refute last_line.line
5446
end
5547

5648
test "reports undefined function errors" do

0 commit comments

Comments
 (0)