summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Lystig Fritchie <slfritchie@snookles.com>2011-08-23 14:17:18 -0500
committerScott Lystig Fritchie <slfritchie@snookles.com>2011-08-23 14:17:18 -0500
commitf79290dc9c1bb4259d1471a35438a83cfcce48da (patch)
tree1f6538f1bc89b5e4bb70781e13bc9fec2fa0bc05
parent34dd0ccdd9135015aef9984fc1047b664da2e361 (diff)
Replace sleep with pause_until_net_kernel_stopped()
-rw-r--r--src/rebar_eunit.erl18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/rebar_eunit.erl b/src/rebar_eunit.erl
index bfaaaa4..cf73e65 100644
--- a/src/rebar_eunit.erl
+++ b/src/rebar_eunit.erl
@@ -472,7 +472,7 @@ reset_after_eunit({OldProcesses, WasAlive, OldAppEnvs, _OldACs}) ->
?DEBUG("Stopping net kernel....\n", []),
erl_epmd:stop(),
net_kernel:stop(),
- timer:sleep(100);
+ pause_until_net_kernel_stopped();
true ->
ok
end,
@@ -553,3 +553,19 @@ wait_until_dead(Pid) when is_pid(Pid) ->
end;
wait_until_dead(_) ->
ok.
+
+pause_until_net_kernel_stopped() ->
+ pause_until_net_kernel_stopped(10).
+
+pause_until_net_kernel_stopped(0) ->
+ exit(net_kernel_stop_failed);
+pause_until_net_kernel_stopped(N) ->
+ try
+ _ = net_kernel:i(),
+ timer:sleep(100),
+ pause_until_net_kernel_stopped(N - 1)
+ catch
+ error:badarg ->
+ ?DEBUG("Stopped net kernel.\n", []),
+ ok
+ end.