0

Using Erlang R16B02, riakc 2.0.0 and meck 0.82:

When trying to mock riakc_pb_socket in my unit tests it blows up. Here's what I get:

> erl -pa ebin deps/*/ebin
Erlang R16B02 (erts-5.10.3) [source-b44b726] [64-bit] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V5.10.3  (abort with ^G)
1> meck:new(riakc_pb_socket).
** exception exit: {compile_forms,{error,[{[],
                                           [{75,erl_lint,{bad_deprecated,{get_index,'_'}}}]}],
                                         [{[],[{75,erl_lint,{undefined_behaviour,[gen_server]}}]}]}}
2>

I found that if I comment this line in riakc_pb_socket.erl and recompile - the problem goes away. Is there a better solution?

-deprecated({get_index,'_', eventually}). 

so afterwards....

> erl -pa ebin deps/*/ebin
Erlang R16B02 (erts-5.10.3) [source-b44b726] [64-bit] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V5.10.3  (abort with ^G)
1> meck:new(riakc_pb_socket).
ok
2> 

> erl -pa ebin deps/*/ebin
Erlang R16B02 (erts-5.10.3) [source-b44b726] [64-bit] [smp:2:2] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V5.10.3  (abort with ^G)
1> code:which(riakc_pb_socket).
"deps/riakc/ebin/riakc_pb_socket.beam"
2> 
Khorkrak
  • 3,911
  • 2
  • 27
  • 37
  • 1
    I've tried various versions of meck and I can't reproduce the problem you're seeing. I've also looked at the erl_lint code and see that the attribute in riakc_pb_socket would not normally trigger this error. What does code:which(riakc_pb_socket) return for you? – Steve Vinoski Nov 18 '14 at 14:16
  • Copied the results to the end of my original post. – Khorkrak Nov 19 '14 at 15:29
  • 1
    Please try these commands in your Erlang shell: `1> {_,Beam,_} = code:get_object_code(riakc_pb_socket).` then `2> {ok,{_,[{abstract_code,{_,AC}}]}} = beam_lib:chunks(Beam,[abstract_code]).` and finally `3> compile:forms(AC, [return_errors]).` – Steve Vinoski Nov 19 '14 at 22:01
  • I tried this both with the -deprecated({get_index,'_', eventually}). commented out and uncommented. The result was the same 3> compile:forms(AC, [return_errors]). {ok,riakc_pb_socket, <<70,79,82,49,0,0,139,72,66,69,65,77,65,116,111,109,0,0, 19,52,0,0,1,117,15,114,...>>} – Khorkrak Nov 20 '14 at 00:13
  • 2
    That's strange then, since those 3 calls are basically what meck is doing. Not sure why these would work but meck would fail. In the meantime I went and built the exact version of Erlang you're using and tried that, but again couldn't reproduce any problems you're seeing. I'm not sure what else to recommend at this point, other than maybe doing a complete clean, removal of all dependencies, and a full rebuild? – Steve Vinoski Nov 20 '14 at 04:11
  • Thanks Steve. I'll give that a try too and see what happens. – Khorkrak Nov 20 '14 at 15:52

0 Answers0