Hi Yuri,<div><br></div><div>You are right, while cover compiling from source works (you can use this as a workaround):</div><div><div>> cover:compile(cover_test, UserOptions = [export_all, debug_info]).</div><div>{ok,cover_test}</div>
<div>> cover_test:test().</div><div>ok</div></div><div><br></div><div>(because UserOptions from the arguments is taken when cover recompiles the instrumented forms)</div><div>when cover compiling from beam UserOptions = [] is taken.</div>
<div>This could be fixed in cover by taking the compile options from the beam file as you assumed how it works.</div><div><br></div><div>Actually the documentation still says that "Only options defining include file directories and
macros are passed to <span class="code">compile:file/2</span>, everything else is
ignored." apparently a patch from Tobias Schlager added export_all to the allowed options of cover:compile for the exact same use case as you had. But this is missing from cover:compile_beam.</div><div><br>
</div><div>May be I try to come up with a patch</div><div><br></div><div>br</div><div>Peter</div><div><br></div><div><br><div><br><div class="gmail_quote">On Tue, Jul 9, 2013 at 11:56 AM, Yuri Lukyanov <span dir="ltr"><<a href="mailto:y.snaky@gmail.com" target="_blank">y.snaky@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It seems that there is no way to cover-compile modules with export_all.<br>
Here is a simple example:<br>
<br>
cover_test.erl:<br>
<br>
-module(cover_test).<br>
test() -> ok.<br>
<br>
<br>
$ erl<br>
Erlang R15B01 (erts-5.9.1) [source] [64-bit] [smp:4:4]<br>
[async-threads:0] [hipe] [kernel-poll:false]<br>
<br>
Eshell V5.9.1 (abort with ^G)<br>
1> c(cover_test, [debug_info,export_all]).<br>
{ok,cover_test}<br>
2> cover_test:test().<br>
ok<br>
3> cover:compile_beam(cover_test).<br>
{ok,cover_test}<br>
4> cover_test:test().<br>
** exception error: undefined function cover_test:test/0<br>
5><br>
<br>
<br>
Could someone explain why it is like this? Is it done on purpose?<br>
Maybe it's a bug?<br>
The reason I want modules to be cover-compiled with +export_all is<br>
that it is sometimes convinient to have unit tests outside of a<br>
module. Before unit tests are run the modules get compiled with<br>
+export_all for tests to be able to access private functions. But the<br>
situation is that it is not possibe in this case to enable coverage<br>
analysys.<br>
_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
</blockquote></div><br></div></div>