mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 11:06:20 +00:00
Merge pull request #102 from dreid/quiet-cover
Redirect cover module output to .eunit/cover.log
This commit is contained in:
commit
773a3dc1f5
1 changed files with 22 additions and 3 deletions
|
@ -128,10 +128,13 @@ eunit(Config, AppFile) ->
|
||||||
Modules = [rebar_utils:beam_to_mod(?EUNIT_DIR, N) || N <- BeamFiles],
|
Modules = [rebar_utils:beam_to_mod(?EUNIT_DIR, N) || N <- BeamFiles],
|
||||||
SrcModules = [rebar_utils:erl_to_mod(M) || M <- SrcErls],
|
SrcModules = [rebar_utils:erl_to_mod(M) || M <- SrcErls],
|
||||||
|
|
||||||
cover_init(Config, BeamFiles),
|
{ok, CoverLog} = cover_init(Config, BeamFiles),
|
||||||
|
|
||||||
EunitResult = perform_eunit(Config, Modules),
|
EunitResult = perform_eunit(Config, Modules),
|
||||||
perform_cover(Config, Modules, SrcModules),
|
perform_cover(Config, Modules, SrcModules),
|
||||||
|
|
||||||
|
cover_close(CoverLog),
|
||||||
|
|
||||||
case EunitResult of
|
case EunitResult of
|
||||||
ok ->
|
ok ->
|
||||||
ok;
|
ok;
|
||||||
|
@ -275,9 +278,25 @@ cover_analyze(Config, Modules, SrcModules) ->
|
||||||
ok
|
ok
|
||||||
end.
|
end.
|
||||||
|
|
||||||
cover_init(false, _BeamFiles) ->
|
cover_close(not_enabled) ->
|
||||||
ok;
|
ok;
|
||||||
|
cover_close(F) ->
|
||||||
|
ok = file:close(F).
|
||||||
|
|
||||||
|
cover_init(false, _BeamFiles) ->
|
||||||
|
{ok, not_enabled};
|
||||||
cover_init(true, BeamFiles) ->
|
cover_init(true, BeamFiles) ->
|
||||||
|
%% Attempt to start the cover server, then set it's group leader to
|
||||||
|
%% .eunit/cover.log, so all cover log messages will go there instead of
|
||||||
|
%% to stdout.
|
||||||
|
{_,CoverPid} = cover:start(),
|
||||||
|
|
||||||
|
{ok, F} = file:open(
|
||||||
|
filename:join([?EUNIT_DIR, "cover.log"]),
|
||||||
|
[write]),
|
||||||
|
|
||||||
|
group_leader(F, CoverPid),
|
||||||
|
|
||||||
%% Make sure any previous runs of cover don't unduly influence
|
%% Make sure any previous runs of cover don't unduly influence
|
||||||
cover:reset(),
|
cover:reset(),
|
||||||
|
|
||||||
|
@ -300,7 +319,7 @@ cover_init(true, BeamFiles) ->
|
||||||
[Beam, Desc])
|
[Beam, Desc])
|
||||||
end,
|
end,
|
||||||
_ = [PrintWarning(Beam, Desc) || {Beam, {error, Desc}} <- Compiled],
|
_ = [PrintWarning(Beam, Desc) || {Beam, {error, Desc}} <- Compiled],
|
||||||
ok
|
{ok, F}
|
||||||
end;
|
end;
|
||||||
cover_init(Config, BeamFiles) ->
|
cover_init(Config, BeamFiles) ->
|
||||||
cover_init(rebar_config:get(Config, cover_enabled, false), BeamFiles).
|
cover_init(rebar_config:get(Config, cover_enabled, false), BeamFiles).
|
||||||
|
|
Loading…
Reference in a new issue