aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tools/src/cover.erl
diff options
context:
space:
mode:
authorTobias Schlager <[email protected]>2010-09-23 11:40:19 +0200
committerTobias Schlager <[email protected]>2010-09-23 11:40:19 +0200
commiteb02beb1c33fafb32e0596d947310d8c17e8bbf2 (patch)
tree91bdb7322d0b1ddf03ec3d3d72d32f3ea3f76c75 /lib/tools/src/cover.erl
parentdd51118499209bbd91c0092d9778897026bde4c6 (diff)
downloadotp-eb02beb1c33fafb32e0596d947310d8c17e8bbf2.tar.gz
otp-eb02beb1c33fafb32e0596d947310d8c17e8bbf2.tar.bz2
otp-eb02beb1c33fafb32e0596d947310d8c17e8bbf2.zip
add user specified compiler options on form reloading
In order to be able to test non-exported functions from another (test) module it is necessary to compile the specific module (at least during the test phase) with the export_all compiler option. This allows complete separation of testing and productive code. At the moment it is not possible to combine this with a test code coverage using the cover module. The problem is that when cover compiling a module using cover:compile_* the code is reloaded into the emulator omitting/filtering the passed user options. In my example above the export_all option would be removed and the non-exported functions cannot be called any more.
Diffstat (limited to 'lib/tools/src/cover.erl')
-rw-r--r--lib/tools/src/cover.erl9
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/tools/src/cover.erl b/lib/tools/src/cover.erl
index c4d1bd1d2f..b8884fed2c 100644
--- a/lib/tools/src/cover.erl
+++ b/lib/tools/src/cover.erl
@@ -229,6 +229,7 @@ compile_modules(Files,Options) ->
{i, Dir} when is_list(Dir) -> true;
{d, _Macro} -> true;
{d, _Macro, _Value} -> true;
+ export_all -> true;
_ -> false
end
end,
@@ -569,7 +570,7 @@ main_process_loop(State) ->
case get_beam_file(Module,BeamFile0,Compiled0) of
{ok,BeamFile} ->
{Reply,Compiled} =
- case do_compile_beam(Module,BeamFile) of
+ case do_compile_beam(Module,BeamFile,[]) of
{ok, Module} ->
remote_load_compiled(State#main_state.nodes,
[{Module,BeamFile}]),
@@ -1227,13 +1228,13 @@ do_compile(File, UserOptions) ->
Options = [debug_info,binary,report_errors,report_warnings] ++ UserOptions,
case compile:file(File, Options) of
{ok, Module, Binary} ->
- do_compile_beam(Module,Binary);
+ do_compile_beam(Module,Binary,UserOptions);
error ->
error
end.
%% Beam is a binary or a .beam file name
-do_compile_beam(Module,Beam) ->
+do_compile_beam(Module,Beam,UserOptions) ->
%% Clear database
do_clear(Module),
@@ -1253,7 +1254,7 @@ do_compile_beam(Module,Beam) ->
%% Compile and load the result
%% It's necessary to check the result of loading since it may
%% fail, for example if Module resides in a sticky directory
- {ok, Module, Binary} = compile:forms(Forms, []),
+ {ok, Module, Binary} = compile:forms(Forms, UserOptions),
case code:load_binary(Module, ?TAG, Binary) of
{module, Module} ->