mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 11:06:20 +00:00
Keep *_tests not automatically included by eunit
This commit is contained in:
parent
0741157a11
commit
b6f575c7fe
1 changed files with 16 additions and 9 deletions
|
@ -126,15 +126,22 @@ eunit(Config, AppFile) ->
|
||||||
rebar_erlc_compiler:doterl_compile(eunit_config(Config),
|
rebar_erlc_compiler:doterl_compile(eunit_config(Config),
|
||||||
?EUNIT_DIR, TestErls),
|
?EUNIT_DIR, TestErls),
|
||||||
|
|
||||||
%% Build a list of all the .beams in ?EUNIT_DIR -- use this for cover
|
%% Build a list of all the .beams in ?EUNIT_DIR -- use this for
|
||||||
%% and eunit testing. Normally you can just tell cover and/or eunit to
|
%% cover and eunit testing. Normally you can just tell cover
|
||||||
%% scan the directory for you, but eunit does a code:purge in conjunction
|
%% and/or eunit to scan the directory for you, but eunit does a
|
||||||
%% with that scan and causes any cover compilation info to be lost.
|
%% code:purge in conjunction with that scan and causes any cover
|
||||||
%% Filter out "*_tests" modules so eunit won't doubly run them and
|
%% compilation info to be lost. Filter out "*_tests" modules so
|
||||||
%% so cover only calculates coverage on production code.
|
%% eunit won't doubly run them and so cover only calculates
|
||||||
BeamFiles = [N || N <- rebar_utils:beams(?EUNIT_DIR),
|
%% coverage on production code. However, keep "*_tests" modules
|
||||||
string:str(N, "_tests.beam") =:= 0],
|
%% that are not automatically included by eunit.
|
||||||
Modules = [rebar_utils:beam_to_mod(?EUNIT_DIR, N) || N <- BeamFiles],
|
AllBeamFiles = rebar_utils:beams(?EUNIT_DIR),
|
||||||
|
{BeamFiles, TestBeamFiles} =
|
||||||
|
lists:partition(fun(N) -> string:str(N, "_tests.beam") =:= 0 end,
|
||||||
|
AllBeamFiles),
|
||||||
|
OtherBeamFiles = TestBeamFiles --
|
||||||
|
[filename:rootname(N) ++ "_tests.beam" || N <- AllBeamFiles],
|
||||||
|
ModuleBeamFiles = BeamFiles ++ OtherBeamFiles,
|
||||||
|
Modules = [rebar_utils:beam_to_mod(?EUNIT_DIR, N) || N <- ModuleBeamFiles],
|
||||||
SrcModules = [rebar_utils:erl_to_mod(M) || M <- SrcErls],
|
SrcModules = [rebar_utils:erl_to_mod(M) || M <- SrcErls],
|
||||||
|
|
||||||
{ok, CoverLog} = cover_init(Config, BeamFiles),
|
{ok, CoverLog} = cover_init(Config, BeamFiles),
|
||||||
|
|
Loading…
Reference in a new issue