diff options
| author | Simon MacMullen <simon@rabbitmq.com> | 2011-07-18 16:32:21 +0100 |
|---|---|---|
| committer | Simon MacMullen <simon@rabbitmq.com> | 2011-07-18 16:32:21 +0100 |
| commit | 2bd44a15bab74e2167820a676e71943826cb1530 (patch) | |
| tree | 8e085709eeba249162ed6828bc79a80667e6932a | |
| parent | 5ee0a57f7bfd74cb86eb9e19dfeb3732533254ec (diff) | |
| download | rabbitmq-server-git-2bd44a15bab74e2167820a676e71943826cb1530.tar.gz | |
I spent a long time trying to get the teardown of the complete supervision hierarchy associated with each test to be completely synchronous and failing. It's much easier to create a new group for each test.
| -rw-r--r-- | src/mirrored_supervisor_tests.erl | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/mirrored_supervisor_tests.erl b/src/mirrored_supervisor_tests.erl index d5c2ceeda0..6d9ea0a0ba 100644 --- a/src/mirrored_supervisor_tests.erl +++ b/src/mirrored_supervisor_tests.erl @@ -58,12 +58,12 @@ test_migrate_twice() -> ?MS:start_child(a, childspec(worker)), Pid1 = pid_of(worker), kill(A, Pid1), - with_sups(fun([_]) -> - Pid2 = pid_of(worker), - kill(B, Pid2), - Pid3 = pid_of(worker), - false = (Pid1 =:= Pid3) - end, [c]) + {ok, C} = start_sup(c), + Pid2 = pid_of(worker), + kill(B, Pid2), + Pid3 = pid_of(worker), + false = (Pid1 =:= Pid3), + kill(C) end, [a, b]). %% Can't start the same child twice @@ -144,6 +144,7 @@ test_start_idempotence() -> %% --------------------------------------------------------------------------- with_sups(Fun, Sups) -> + inc_group(), Pids = [begin {ok, Pid} = start_sup(Sup), Pid end || Sup <- Sups], Fun(Pids), [kill(Pid) || Pid <- Pids, is_process_alive(Pid)], @@ -153,7 +154,7 @@ start_sup(Spec) -> start_sup(Spec, group). start_sup({Name, ChildSpecs}, Group) -> - {ok, Pid} = start_sup0(Name, Group, ChildSpecs), + {ok, Pid} = start_sup0(Name, get_group(Group), ChildSpecs), %% We are not a supervisor, when we kill the supervisor we do not %% want to die! unlink(Pid), @@ -178,6 +179,16 @@ pid_of(Id) -> {received, Pid, ping} = call(Id, ping), Pid. +inc_group() -> + Count = case get(counter) of + undefined -> 0; + C -> C + end + 1, + put(counter, Count). + +get_group(Group) -> + {Group, get(counter)}. + call(Id, Msg) -> call(Id, Msg, 100, 10). call(Id, Msg, 0, _Decr) -> |
