Skip to content

ExUnit: Raise explaining what failed on invalid tags #14707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

eksperimental
Copy link
Contributor

Errors were a bit cryptic when running mix test.

@tag "a" before:

== Compilation error in file test/ex_unit_tag_error_test.exs ==
** (FunctionClauseError) no function clause matching in anonymous fn/2 in ExUnit.Case.normalize_tags/1

    The following arguments were given to anonymous fn/2 in ExUnit.Case.normalize_tags/1:

        # 1
        "a"

        # 2
        %{}

    (ex_unit 1.18.4) lib/ex_unit/case.ex:896: anonymous fn/2 in ExUnit.Case.normalize_tags/1
    (elixir 1.18.4) lib/enum.ex:2546: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ex_unit 1.18.4) lib/ex_unit/case.ex:669: ExUnit.Case.register_test/6
    test/ex_unit_tag_error_test.exs:7: (module)
    (elixir 1.18.4) lib/kernel/parallel_compiler.ex:542: Kernel.ParallelCompiler.require_file/2
    (elixir 1.18.4) lib/kernel/parallel_compiler.ex:425: anonymous fn/5 in Kernel.ParallelCompiler.spawn_workers/8

@tag "a" now:

== Compilation error in file test/ex_unit_tag_error_test.exs ==
** (RuntimeError) an invalid value for a tag was used; expected an atom or a keyword list, got: "a"
    (ex_unit 1.20.0-dev) lib/ex_unit/case.ex:953: anonymous fn/2 in ExUnit.Case.normalize_tags/1
    (elixir 1.20.0-dev) lib/enum.ex:2580: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ex_unit 1.20.0-dev) lib/ex_unit/case.ex:715: ExUnit.Case.register_test/6
    test/ex_unit_tag_error_test.exs:7: (module)
    (elixir 1.20.0-dev) lib/kernel/parallel_compiler.ex:599: Kernel.ParallelCompiler.require_file/2
    (elixir 1.20.0-dev) lib/kernel/parallel_compiler.ex:482: anonymous fn/5 in Kernel.ParallelCompiler.spawn_workers/8

@tag [:foo, :bar] before:

== Compilation error in file test/ex_unit_tag_error_test.exs ==
** (ArgumentError) argument error
    (stdlib 6.2) :maps.from_list([:foo, :bar])
    (elixir 1.18.4) lib/enum.ex:1543: Enum.into_map/1
    (elixir 1.18.4) lib/enum.ex:2546: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ex_unit 1.18.4) lib/ex_unit/case.ex:669: ExUnit.Case.register_test/6
    test/ex_unit_tag_error_test.exs:7: (module)
    (elixir 1.18.4) lib/kernel/parallel_compiler.ex:542: Kernel.ParallelCompiler.require_file/2
    (elixir 1.18.4) lib/kernel/parallel_compiler.ex:425: anonymous fn/5 in Kernel.ParallelCompiler.spawn_workers/8

@tag [:foo, :bar] now:

== Compilation error in file test/ex_unit_tag_error_test.exs ==
** (RuntimeError) an invalid value for a tag was used; expected an atom or a keyword list, got: [:foo, :bar]
    (ex_unit 1.20.0-dev) lib/ex_unit/case.ex:953: anonymous fn/2 in ExUnit.Case.normalize_tags/1
    (elixir 1.20.0-dev) lib/enum.ex:2580: Enum."-reduce/3-lists^foldl/2-0-"/3
    (ex_unit 1.20.0-dev) lib/ex_unit/case.ex:715: ExUnit.Case.register_test/6
    test/ex_unit_tag_error_test.exs:7: (module)
    (elixir 1.20.0-dev) lib/kernel/parallel_compiler.ex:599: Kernel.ParallelCompiler.require_file/2
    (elixir 1.20.0-dev) lib/kernel/parallel_compiler.ex:482: anonymous fn/5 in Kernel.ParallelCompiler.spawn_workers/8


Copy link
Contributor

@sabiwara sabiwara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💜

@josevalim josevalim merged commit f93919f into elixir-lang:main Aug 8, 2025
13 checks passed
@josevalim
Copy link
Member

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants