Skip to content
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

Can not meck ets module. #141

Closed
jinq0123 opened this issue May 7, 2015 · 4 comments
Closed

Can not meck ets module. #141

jinq0123 opened this issue May 7, 2015 · 4 comments
Labels

Comments

@jinq0123
Copy link

jinq0123 commented May 7, 2015

my_test() ->
meck:new(ets, [unstick]),
meck:unload(ets),
ok.

m: my_test (module 'm')...skipped
undefined
unexpected termination of test process
::{compile_forms,{error,[],
[{"ets.erl",
[{50,erl_lint,
{deprecated_builtin_type,{...},...}}]}]}}

@eproxus
Copy link
Owner

eproxus commented May 7, 2015

Can you replace the call to meck:new(ets, [unstick]) with this code and paste the whole error message?

    io:format(user, "MECK ERROR: ~p~n", [(catch meck:new(ets, [unstick]))]).

I suspect this is because Ets has built-in functions (functions coded in C) that Meck cannot deal with in runtime. This is a limitation of Meck that unfortunately cannot be fixed (or at least it is very hard).

@jinq0123
Copy link
Author

jinq0123 commented May 9, 2015

MECK ERROR: {'EXIT',
                {{compile_forms,
                     {error,[],
                         [{"ets.erl",
                           [{50,erl_lint,
                             {deprecated_builtin_type,
                                 {tid,0},
                                 {ets,tid},
                                 "OTP 18.0"}}]}]}},
                 [{meck_proc,start,
                      [ets,[unstick]],
                      [{file,"src/meck_proc.erl"},{line,96}]},
                  {cluster_server_info,other_test,0,
                      [{file,"src/cluster/cluster_server_info.erl"},
                       {line,61}]},
                  {eunit_test,'-mf_wrapper/2-fun-0-',2,
                      [{file,"eunit_test.erl"},{line,266}]},
                  {eunit_test,run_testfun,1,
                      [{file,"eunit_test.erl"},{line,65}]},
                  {eunit_proc,run_test,1,[{file,"eunit_proc.erl"},{line,506}]},
                  {eunit_proc,with_timeout,3,
                      [{file,"eunit_proc.erl"},{line,331}]},
                  {eunit_proc,handle_test,2,
                      [{file,"eunit_proc.erl"},{line,489}]},
                  {eunit_proc,tests_inorder,3,
                      [{file,"eunit_proc.erl"},{line,431}]}]}}
cluster_server_info: other_test (module 'cluster_server_info')...*skipped*
undefined
*unexpected termination of test process*
::{compile_forms,{error,[],
                        [{"ets.erl",
                          [{50,erl_lint,
                            {deprecated_builtin_type,{...},...}}]}]}}

@eproxus
Copy link
Owner

eproxus commented May 13, 2015

Can reproduce on 17.5, but not on R16B03-1. One thing to note is that Meck is internally using ets, so mocking ets could be tricky/impossible in the first place. For example (R16B03-1):

17> meck:new(ets, [unstick]).
ok
18> meck:expect(ets, i, 0, ok).
ok
19> ets:i().

=ERROR REPORT==== 13-May-2015::10:13:33 ===
** Generic server ets_meck terminating
** Last message in was {get_result_spec,i,[]}
** When Server state == {state,ets,[...]}
** Reason for termination ==
** {undef,[{ets,match_spec_run,[[{[]}],<<>>],[]},
           {meck_args_matcher,match,2,
                              [{file,"src/meck_args_matcher.erl"},{line,85}]},
           ...]}

If you want to mock away ets usage, I'd suggest mocking the module that uses ets instead of ets itself.

@eproxus
Copy link
Owner

eproxus commented Nov 21, 2016

Closing because of inactivity. Please re-open if it is still an issue!

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

No branches or pull requests

2 participants