使用Erlang R16B02,riakc 2.0.0和meck 0.82:
当我在单元测试中尝试模拟riakc_pb_socket时,它会爆炸。这是我得到的:
> 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>
我发现如果我在riakc_pb_socket.erl中注释这一行并重新编译 - 问题就会消失。有更好的解决方案吗?
-deprecated({get_index,'_', eventually}).
以后......
> 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>