jjh42 / mock

Mocking library for Elixir language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mock raises random errors with OTP 20

tompave opened this issue · comments

I use mock 0.2.1 in my ExUnit test suite. Tests pass with Elixir 1.4 and OTP 18 and 19, but I get errors with OTP 20. The errors happen in some, but not all, tests that create mocks.

     ** (ErlangError) erlang error: {:compile_forms, {:error, [{[], [{:none, :compile, {:crash, :lint_module, {:badarg, [{:erlang, :atom_to_list, [[GenServer]], []}, {:erl_lint, :is_latin1_name, 1, [file: 'erl_lint.erl', line: 3055]}, {:erl_lint, :check_module_name, 3, [file: 'erl_lint.erl', line: 3048]}, {:erl_lint, :behaviour_callbacks, 3, [file: 'erl_lint.erl', line: 973]}, {:erl_lint, :all_behaviour_callbacks, 3, [file: 'erl_lint.erl', line: 934]}, {:erl_lint, :behaviour_check, 2, [file: 'erl_lint.erl', line: 921]}, {:erl_lint, :post_traversal_check, 2, [file: 'erl_lint.erl', line: 893]}, {:erl_lint, :module, 3, [file: 'erl_lint.erl', line: 536]}, {:compile, :lint_module, 2, [file: 'compile.erl', line: 1109]}, {:compile, :"-internal_comp/5-anonymous-1-", 3, [file: 'compile.erl', line: 342]}, {:compile, :fold_comp, 4, [file: 'compile.erl', line: 369]}, {:compile, :internal_comp, 5, [file: 'compile.erl', line: 353]}, {:compile, :"-do_compile/2-anonymous-0-", 2, [file: 'compile.erl', line: 177]}, {:compile, :"-do_compile/2-anonymous-1-", 1, [file: 'compile.erl', line: 190]}]}}}]}], []}}
     stacktrace:
       (meck) src/meck_proc.erl:95: :meck_proc.start(MyMocked.ModuleFoo, [:passthrough])
       test/my_mocked/module_foo_test.exs:395: anonymous fn/2 in MyMocked.ModuleFooTest.test the test description I typed for this specific test case/1
       (elixir) lib/enum.ex:1755: Enum."-reduce/3-lists^foldl/2-0-"/3
       test/my_mocked/module_foo_test.exs:395: (test)

It looks like that sometimes the mocks are not cleared and "leak" in other tests, judging from this other kind of errors that happens randomly:

     ** (UndefinedFunctionError) function Foo.Bar.baz/0 is undefined or private. Did you mean one of:

           * baz/0

Apparently this was caused by meck. Fixed in this commit.
eproxus/meck@7c5548e

New version of meck was released. The issue is solved with meck >= 0.8.5.

I think @Olshansk will be making a releasing a version of mock soon which should pull in the update meck.