sproutapp / pavlov

A BDD framework for your Elixir projects

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Context names can easily hit erlang's atom length limitation

mspanc opened this issue · comments

It seems that internally in pavlov context and test names are concatenated and converted into atom.

Unfortunately it leads to case in which it's super simple to hit internal erlang limit of atom length (255 characters) just with simple nesting.

Test case:

iex(2)> :erlang.binary_to_atom("Elixir.MyApp.UserTest.POST (base_url).if Authorization header was passed.and it uses Bearer scheme.and the token passed was granted.and access token owner has permissions to create new record of this type.but no POST data was passed.and something something happens", :utf8)
** (SystemLimitError) a system limit has been reached
    :erlang.binary_to_atom("Elixir.MyApp.UserTest.POST (base_url).if Authorization header was passed.and it uses Bearer scheme.and the token passed was granted.and access token owner has permissions to create new record of this type.but no POST data was passed.and something something happens", :utf8)

I even got that once while running mix test

7:18:09.667 [error] 'File operation error: enametoolong. Target: Elixir.Plumber.Channel.Input.Stream.RTPControllerTest.POST (base_url).if Authorization header was passed.and it uses Bearer scheme.and the token passed was granted.and access token owner has permissions to create new record.and some POST data were passed.beam. Function: get_file. Process: code_server.'
** (SystemLimitError) a system limit has been reached
    :erlang.binary_to_atom("Elixir.Plumber.Channel.Input.Stream.RTPControllerTest.POST (base_url).if Authorization header was passed.and it uses Bearer scheme.and the token passed was granted.and access token owner has permissions to create new record.and some POST data were passed.and they are valid", :utf8)
    (elixir) src/elixir_aliases.erl:103: :elixir_aliases.concat/1
    test/controllers/channel/input/stream/rtp_controller_test.exs:107: (module)
    test/controllers/channel/input/stream/rtp_controller_test.exs:106: (module)

It seems that this is the cause: https://github.com/sproutapp/pavlov/blob/master/lib/case.ex#L87

IMO instead of relying on internal module name to determine the submodule hierarchy, it should be better to keep such hierarchy tree in separate storage (maybe in Agent?), and internally assign unique module names.