diff options
author | Dave Smith <dizzyd@dizzyd.com> | 2011-08-05 10:15:15 -0700 |
---|---|---|
committer | Dave Smith <dizzyd@dizzyd.com> | 2011-08-05 10:15:15 -0700 |
commit | 773a3dc1f56cebc146ceef6d9c46a0906dfaca7d (patch) | |
tree | 92dcf10a5ede45306d2f257f4f3aa2bb73bcbea2 | |
parent | 798e5102483346c82837e5b46da94868f6e169c8 (diff) | |
parent | 0edf52b5399baf68fbb158c9cb7d9ca06010d8f7 (diff) |
Merge pull request #102 from dreid/quiet-cover
Redirect cover module output to .eunit/cover.log
-rw-r--r-- | src/rebar_eunit.erl | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/rebar_eunit.erl b/src/rebar_eunit.erl index 8f7c682..ad56a34 100644 --- a/src/rebar_eunit.erl +++ b/src/rebar_eunit.erl @@ -128,10 +128,13 @@ eunit(Config, AppFile) -> Modules = [rebar_utils:beam_to_mod(?EUNIT_DIR, N) || N <- BeamFiles], SrcModules = [rebar_utils:erl_to_mod(M) || M <- SrcErls], - cover_init(Config, BeamFiles), + {ok, CoverLog} = cover_init(Config, BeamFiles), + EunitResult = perform_eunit(Config, Modules), perform_cover(Config, Modules, SrcModules), + cover_close(CoverLog), + case EunitResult of ok -> ok; @@ -275,9 +278,25 @@ cover_analyze(Config, Modules, SrcModules) -> ok end. -cover_init(false, _BeamFiles) -> +cover_close(not_enabled) -> ok; +cover_close(F) -> + ok = file:close(F). + +cover_init(false, _BeamFiles) -> + {ok, not_enabled}; 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 cover:reset(), @@ -300,7 +319,7 @@ cover_init(true, BeamFiles) -> [Beam, Desc]) end, _ = [PrintWarning(Beam, Desc) || {Beam, {error, Desc}} <- Compiled], - ok + {ok, F} end; cover_init(Config, BeamFiles) -> cover_init(rebar_config:get(Config, cover_enabled, false), BeamFiles). |