Skip to content

Commit b566edc

Browse files
eksperimentaljosevalim
authored andcommitted
ExUnit: Raise explaining what failed on invalid tags (#14707)
1 parent 297f1f3 commit b566edc

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

lib/ex_unit/lib/ex_unit/case.ex

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -940,9 +940,19 @@ defmodule ExUnit.Case do
940940

941941
defp normalize_tags(tags) do
942942
Enum.reduce(Enum.reverse(tags), %{}, fn
943-
{key, value}, acc -> Map.put(acc, key, value)
944-
tag, acc when is_atom(tag) -> Map.put(acc, tag, true)
945-
tag, acc when is_list(tag) -> Enum.into(tag, acc)
943+
{key, value}, acc ->
944+
Map.put(acc, key, value)
945+
946+
tag, acc when is_atom(tag) ->
947+
Map.put(acc, tag, true)
948+
949+
tag, acc ->
950+
if Keyword.keyword?(tag) do
951+
Enum.into(tag, acc)
952+
else
953+
raise "an invalid value for a tag was used. " <>
954+
"Expected an atom or a keyword list, got: #{inspect(tag)}"
955+
end
946956
end)
947957
end
948958
end

0 commit comments

Comments
 (0)