Skip to content

Commit b074e6b

Browse files
lukaszsamsonjosevalim
authored andcommitted
Fix ex_unit formatter crash when find_diff returns nil (#14939)
1 parent bfe7315 commit b074e6b

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/ex_unit/lib/ex_unit/formatter.ex

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,10 +513,15 @@ defmodule ExUnit.Formatter do
513513

514514
defp format_diff(left, right, context, formatter) do
515515
if has_value?(left) and has_value?(right) do
516-
{result, env} = find_diff(left, right, context)
517-
result = if formatter.(:diff_enabled?, false), do: result
518-
hints = Enum.map(env.hints, &{:hint, format_hint(&1)})
519-
{result, hints}
516+
case find_diff(left, right, context) do
517+
{result, env} ->
518+
result = if formatter.(:diff_enabled?, false), do: result
519+
hints = Enum.map(env.hints, &{:hint, format_hint(&1)})
520+
{result, hints}
521+
522+
nil ->
523+
{nil, []}
524+
end
520525
else
521526
{nil, []}
522527
end

0 commit comments

Comments
 (0)