aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKlas Johansson <[email protected]>2011-04-17 22:05:43 +0200
committerKlas Johansson <[email protected]>2011-04-17 22:05:43 +0200
commit0e7c557a9909f531530ee4742eb04ce23f03e3d6 (patch)
tree67e445b39eb09d9886e93dfc7fbbba3a650534fa
parent23906a01725f4494b8816c242926d08aeca0ef67 (diff)
downloadotp-0e7c557a9909f531530ee4742eb04ce23f03e3d6.tar.gz
otp-0e7c557a9909f531530ee4742eb04ce23f03e3d6.tar.bz2
otp-0e7c557a9909f531530ee4742eb04ce23f03e3d6.zip
Wait until all eunit listeners terminate
Ensure that all eunit listeners (like eunit_surefire) get the chance to finish their work before terminating. Prior to this fix, the eunit_surefire XML was sometimes not generated.
-rw-r--r--lib/eunit/src/eunit.erl10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/eunit/src/eunit.erl b/lib/eunit/src/eunit.erl
index 4a86a108cf..da35c5c2ec 100644
--- a/lib/eunit/src/eunit.erl
+++ b/lib/eunit/src/eunit.erl
@@ -157,6 +157,7 @@ test_run(Reference, Listeners) ->
receive
{done, Reference} ->
cast(Listeners, {stop, Reference, self()}),
+ wait_until_listeners_have_terminated(Listeners),
receive
{result, Reference, Result} ->
Result
@@ -169,6 +170,15 @@ cast([P | Ps], Msg) ->
cast([], _Msg) ->
ok.
+wait_until_listeners_have_terminated([P | Ps]) ->
+ MRef = erlang:monitor(process, P),
+ receive
+ {'DOWN', MRef, process, P, _} ->
+ wait_until_listeners_have_terminated(Ps)
+ end;
+wait_until_listeners_have_terminated([]) ->
+ ok.
+
%% TODO: functions that run tests on a given node, not a given server
%% TODO: maybe some functions could check for a globally registered server?
%% TODO: some synchronous but completely quiet interface function