One could argue that rebar_eunit does some pretty dangerous stuff when
trying to clean up after a test run, but specifically, it tells the
Application Controller to delete everything returned by
application:get_all_env(App). Unfortunately, included_applications
also goes, which can lead to a crash in application_controller, if
the application is subsequently unloaded.
This patch attempts the smallest possible fix: remove all env
variables except included_applications.
Normally, Rebar runs eunit tests in the order the beam files are
stored in the file system (see rebar_utils:beams). However, sometimes
it is desirable to run the tests in a different order (e.g. to
reproduce an error found on a build server). For that case, it would
make sense to use the 'suites' parameter not just for selecting which
modules to consider, but also for choosing the order.
Cover gets slower and slower for each application. This is due to the
cover_server internal state. Stopping the cover server between
eunit+cover runs, emptying the cover_server state, gives a ~5-6x speed
improvement when analyzing many Erlang modules. Stopping the cover
server replaces the earlier practice of doing a cover:reset before each
run. On a project consisting of 62 dependencies with a total of 1866
Erlang modules the running time of rebar eunit decreased from ~20
minutes to ~3 minutes.
Make sure files from erl_opts->src_dirs are copied to .eunit for cover
inspection.
Without this patch cover failed to find source files which were in
src_dirs, and threw the following exception:
ERROR: eunit failed while processing
/path/to/project:
{'EXIT',{{badmatch,{error,no_source_code_found}},
[{rebar_eunit,'-cover_analyze/3-fun-0-',1,
[{file,"src/rebar_eunit.erl"},{line,280}]},
{lists,foreach,2,[{file,"lists.erl"},{line,1262}]},
{rebar_eunit,cover_analyze,3,
[{file,"src/rebar_eunit.erl"},{line,279}]},
{rebar_eunit,eunit,2,[{file,"src/rebar_eunit.erl"},{line,140}]},
{rebar_core,run_modules,4,[{file,"src/rebar_core.erl"},{line,425}]},
{rebar_core,execute,5,[{file,"src/rebar_core.erl"},{line,359}]},
{rebar_core,process_dir0,6,[{file,"src/rebar_core.erl"},{line,223}]},
{rebar_core,process_dir,4,
[{file,"src/rebar_core.erl"},{line,130}]}]}}
Now all source files are copied to .eunit.