elixir-lang / elixir

Elixir is a dynamic, functional language for building scalable and maintainable applications
https://elixir-lang.org/
Apache License 2.0
24.51k stars 3.38k forks source link

ExUnit test names cannot contain special characters on Erlang < 20 #7321

Closed victorolinasc closed 6 years ago

victorolinasc commented 6 years ago

Precheck

Environment & Current behaviour

See link of issue: https://travis-ci.org/victorolinasc/junit-formatter/jobs/337734064

This was tested with Elixir 1.6.0-rc1 but its confirmed on any Elixir 1.6 versions and prior.

Current behavior

Here is the error currently:

  1) test it can include unicode in test names (FormatterTest)
     test/formatter_test.exs:145
     ** (ArgumentError) argument error
     code: defmodule UnicodeTest do
     stacktrace:
       :erlang.binary_to_atom("test make sure 3 ≤ 4", :utf8)
       (ex_unit) lib/ex_unit/case.ex:457: ExUnit.Case.register_test/4
       test/formatter_test.exs:149: (module)
       (elixir) src/elixir_compiler.erl:82: :elixir_compiler.dispatch/5
       (elixir) src/elixir_module.erl:223: :elixir_module.eval_form/6
       (elixir) src/elixir_module.erl:77: :elixir_module.compile/5
       (elixir) src/elixir_lexical.erl:18: :elixir_lexical.run/3
       test/formatter_test.exs:146: (test)

Expected behavior

The conversion from string to atom in ExUnit should either:

  1. Ensure only ASCII characters and raise with a better message otherwise.
  2. Exclude these chracters and show a warning during build.

Option 2 would allow tests that run on OTP 20 to also run on OTP 19 and below.

Any of these fixes probably should change here and here.

I can send a PR if any of the above is decided upon.

josevalim commented 6 years ago

Yes, this is known. Anything that converts to function names will have this issue. Given Elixir v1.7 will be the last version to support 19, I will mark this as "won't fix" since it will be fixed once everyone is running on Erlang 20+. Thanks for opening the issue!