Skip to content

Commit 13c334f

Browse files
committed
Fix expectation error reporting in doctests
1 parent 875b4c7 commit 13c334f

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

lib/ex_unit/lib/ex_unit/doc_test.ex

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -184,16 +184,21 @@ defmodule ExUnit.DocTest do
184184
instead: instead ],
185185
stack
186186
end
187-
rescue e ->
188-
location = [line: unquote(line), file: Path.relative_to(unquote(file), System.cwd!)]
189-
stack = [{ unquote(module), :__MODULE__, 0, location }]
190-
raise ExUnit.ExpectationError,
191-
[ prelude: "Expected doctest",
192-
expected: unquote(test.expr),
193-
actual: "without an exception",
194-
reason: "complete",
195-
instead: e ],
196-
stack
187+
rescue
188+
e in [ExUnit.ExpectationError] ->
189+
location = [line: unquote(line), file: Path.relative_to(unquote(file), System.cwd!)]
190+
stack = [{ unquote(module), :__MODULE__, 0, location }]
191+
raise e, [], stack
192+
e ->
193+
location = [line: unquote(line), file: Path.relative_to(unquote(file), System.cwd!)]
194+
stack = [{ unquote(module), :__MODULE__, 0, location }]
195+
raise ExUnit.ExpectationError,
196+
[ prelude: "Expected doctest",
197+
expected: unquote(test.expr),
198+
actual: "without an exception",
199+
reason: "complete",
200+
instead: e ],
201+
stack
197202
end
198203
end
199204
if do_import do

0 commit comments

Comments
 (0)