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

Allow meck to build under Erlang 17.0-rc2 and Erlang R16B03-1 #118

Merged
merged 8 commits into from
Mar 31, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ notifications:
- hello@alind.io
otp_release:
- R16B03-1
- R16B
- R15B03
- R14B04
before_script: "make get-deps"
script: "make all"
2 changes: 2 additions & 0 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
%% Compiler Options ===========================================================
{erl_opts, [
%% Erlang releases after 17 don't put R in front of their name, and also require dict() to be written like dict:dict()
{platform_define, "^[0-9]+", namespaced_dicts},
warn_export_all,
warn_export_vars,
warn_shadow_vars,
Expand Down
29 changes: 16 additions & 13 deletions src/meck_proc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,15 @@
%%% Definitions
%%%============================================================================

-ifdef(namespaced_dicts).
-type meck_dict() :: dict:dict().
-else.
-type meck_dict() :: dict().
-endif.

-record(state, {mod :: atom(),
can_expect :: any | [{Mod::atom(), Ari::byte()}],
expects :: dict(),
expects :: meck_dict(),
valid = true :: boolean(),
history = [] :: meck_history:history() | undefined,
original :: term(),
Expand Down Expand Up @@ -412,7 +418,7 @@ resolve_can_expect(Mod, Exports, Options) ->

-spec init_expects(Exports::[meck_expect:func_ari()] | undefined,
Options::[proplists:property()]) ->
dict().
meck_dict().
init_expects(Exports, Options) ->
Passthrough = proplists:get_bool(passthrough, Options),
StubAll = proplists:is_defined(stub_all, Options),
Expand Down Expand Up @@ -449,8 +455,8 @@ check_if_being_reloaded(#state{reload = undefined}) ->
check_if_being_reloaded(_S) ->
erlang:error(concurrent_reload).

-spec do_get_result_spec(Expects::dict(), Func::atom(), Args::[any()]) ->
{meck_ret_spec:result_spec() | undefined, NewExpects::dict()}.
-spec do_get_result_spec(Expects::meck_dict(), Func::atom(), Args::[any()]) ->
{meck_ret_spec:result_spec() | undefined, NewExpects::meck_dict()}.
do_get_result_spec(Expects, Func, Args) ->
FuncAri = {Func, erlang:length(Args)},
Expect = dict:fetch(FuncAri, Expects),
Expand Down Expand Up @@ -480,20 +486,20 @@ validate_expect(Mod, Func, Ari, CanExpect) ->
end.

-spec store_expect(Mod::atom(), meck_expect:func_ari(),
meck_expect:expect(), Expects::dict()) ->
{NewExpects::dict(), CompilerPid::pid()}.
meck_expect:expect(), Expects::meck_dict()) ->
{NewExpects::meck_dict(), CompilerPid::pid()}.
store_expect(Mod, FuncAri, Expect, Expects) ->
NewExpects = dict:store(FuncAri, Expect, Expects),
compile_expects(Mod, NewExpects).

-spec do_delete_expect(Mod::atom(), meck_expect:func_ari(), Expects::dict()) ->
{NewExpects::dict(), CompilerPid::pid()}.
-spec do_delete_expect(Mod::atom(), meck_expect:func_ari(), Expects::meck_dict()) ->
{NewExpects::meck_dict(), CompilerPid::pid()}.
do_delete_expect(Mod, FuncAri, Expects) ->
NewExpects = dict:erase(FuncAri, Expects),
compile_expects(Mod, NewExpects).

-spec compile_expects(Mod::atom(), Expects::dict()) ->
{NewExpects::dict(), CompilerPid::pid()}.
-spec compile_expects(Mod::atom(), Expects::meck_dict()) ->
{NewExpects::meck_dict(), CompilerPid::pid()}.
compile_expects(Mod, Expects) ->
%% If the recompilation is made by the server that executes a module
%% no module that is called from meck_code:compile_and_load_forms/2
Expand Down Expand Up @@ -643,6 +649,3 @@ is_expired({MacroSecs, Secs, MicroSecs}) ->
(NowMacroSecs == MacroSecs andalso NowSecs > Secs) orelse
(NowMacroSecs == MacroSecs andalso NowSecs == Secs andalso
NowMicroSecs > MicroSecs)).



6 changes: 4 additions & 2 deletions test.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@
%% Compiler Options ===========================================================
% FIXME: Add warnings_as_errors once Hamcrest is fixed
{erl_opts, [
debug_info,
{platform_define, "R14|R15|R16(B0[1-2])?", cover_empty_compile_opts}
%% Erlang releases after 17 don't put R in front of their name, and also require dict() to be written like dict:dict()
{platform_define, "^[0-9]+", namespaced_dicts},
{platform_define, "^R(?!16B03)", cover_empty_compile_opts},
debug_info
]}.

%% Eunit Options ==============================================================
Expand Down
2 changes: 1 addition & 1 deletion test/meck_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ cover_options_({_OldPath, Src, Module}) ->
% 2 instead of 3, as above
?assertEqual({ok, {Module, {2,0}}}, cover:analyze(Module, module)).

-ifndef(cover_empty_compile_opts).
-ifdef(cover_empty_compile_opts).
-define(compile_options, []).
-else.
-define(compile_options, [{i,"../test/include"},{d,'TEST',true}]).
Expand Down