Skip to content

Commit

Permalink
Merge pull request #32 from djnym/master
Browse files Browse the repository at this point in the history
Filter out parse_transforms from compilation options
  • Loading branch information
eproxus committed Jul 25, 2011
2 parents efe3756 + 7be40df commit 2e82eae
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/meck_mod.erl
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ compile_and_load_forms(AbsCode, Opts) ->
compile_options(BeamFile) when is_binary(BeamFile) ->
case beam_lib:chunks(BeamFile, [compile_info]) of
{ok, {_, [{compile_info, Info}]}} ->
proplists:get_value(options, Info);
filter_options(proplists:get_value(options, Info));
_ ->
[]
end;
compile_options(Module) ->
proplists:get_value(options, Module:module_info(compile)).
filter_options(proplists:get_value(options, Module:module_info(compile))).

-spec rename_module(erlang_form(), module()) -> erlang_form().
rename_module([{attribute, Line, module, _OldName}|T], NewName) ->
Expand All @@ -93,3 +93,10 @@ load_binary(Name, Binary) ->
{module, Name} -> ok;
{error, Reason} -> exit({error_loading_module, Name, Reason})
end.

% parse transforms have already been applied to the abstract code in the
% module, and often are not always available when compiling the forms, so
% filter them out of the options
filter_options (Options) ->
lists:filter(fun({parse_transform,_}) -> false; (_) -> true end, Options).

0 comments on commit 2e82eae

Please sign in to comment.