summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Reid <dreid@dreid.org>2011-08-08 09:46:58 -0700
committerTuncer Ayaz <tuncer.ayaz@gmail.com>2011-08-10 18:32:58 +0200
commit6736e3147e8587c0c22aff5040e80f1129ce9e79 (patch)
tree95b92547cfec0e388cd1706ac32c44ffb4bded20
parent2911d48fb1941b56d7660d8e8b51e395832a3a0b (diff)
Fix handling of {already_started,Pid} from cover:start
Previous patch erroneously assumed that cover:start() returned {already_started,Pid} in the cases where cover was already started. We now turn {error,{already_started,Pid}} into {ok, Pid} and return {error, Reason} if we encounter an error we do not know about, this will cause a nice and violent badmatch to stop everything.
-rw-r--r--src/rebar_eunit.erl12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/rebar_eunit.erl b/src/rebar_eunit.erl
index ad56a34..d42ed1f 100644
--- a/src/rebar_eunit.erl
+++ b/src/rebar_eunit.erl
@@ -288,8 +288,16 @@ cover_init(false, _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(),
+ %% to stdout. If the cover server is already started we'll reuse that
+ %% pid.
+ {ok, CoverPid} = case cover:start() of
+ {ok, P} ->
+ {ok, P};
+ {error,{already_started, P}} ->
+ {ok, P};
+ {error, Reason} ->
+ {error, Reason}
+ end,
{ok, F} = file:open(
filename:join([?EUNIT_DIR, "cover.log"]),