How do I export all functions for common test only?

7k Views Asked by At

I have been trying to export all the functions in an erlang module for use in a common test SUITE, not an eunit module. So far it has not worked for me. I am using rebar to run the SUITE, and I came across this question (http://lists.basho.com/pipermail/rebar_lists.basho.com/2011-October/001141.html), which is essentially exactly what I want to do, but the method will not work for me.

I have also added {plugins, [rebar_ct]}. into rebar.config but it has made no difference. I should point out all my tests pass when I export the functions normally, but I want to avoid this. Any help would be great thanks.

2

There are 2 best solutions below

7
Michael On

The compiler will cause all functions in a module to be exported if you add this into it:

-compile(export_all).

Or you could do it based on defs, like:

-ifdef(EXPORTALL).
-compile(export_all).
-endif.

That will only export everything if you have {d, 'EXPORTALL', true} in your rebar config erl_opts setting, e.g. something like:

{erl_opts, [
    {d, 'EXPORTALL', true}
    ]}.

If that doesn't work, make sure you don't have erl_opts twice in your rebar config.

2
Pascal On

with rebar3 you can define in the config file extra option for the compilation for common test:

{ct_compile_opts, []}.

her you can add export_all which will be available for common test only. not sure it exists for rebar.