diff options
author | Matthias Radestock <matthias@rabbitmq.com> | 2010-07-29 22:11:38 +0100 |
---|---|---|
committer | Matthias Radestock <matthias@rabbitmq.com> | 2010-07-29 22:11:38 +0100 |
commit | b599590d8da76e1e0004bf5ac75493a61c5dc98c (patch) | |
tree | 3742f9f557a126bd22c557f69d4fc2eee3ca39b2 | |
parent | 45567170315af293e8f05711dd5e54f839005b18 (diff) | |
download | rabbitmq-server-b599590d8da76e1e0004bf5ac75493a61c5dc98c.tar.gz |
simplifying refactorbug21396
-rw-r--r-- | src/test_sup.erl | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/src/test_sup.erl b/src/test_sup.erl index 7ed606a6..f41793bc 100644 --- a/src/test_sup.erl +++ b/src/test_sup.erl @@ -37,19 +37,15 @@ init/1, start_child/0]). test_supervisor_delayed_restart() -> - passed = test_supervisor_delayed_restart( - simple_one_for_one_terminate, - fun (SupPid) -> - {ok, _ChildPid} = supervisor2:start_child(SupPid, []), - ok - end), - passed = test_supervisor_delayed_restart( - one_for_one, - fun (_SupPid) -> ok end). + passed = with_sup(simple_one_for_one_terminate, + fun (SupPid) -> + {ok, _ChildPid} = + supervisor2:start_child(SupPid, []), + test_supervisor_delayed_restart(SupPid) + end), + passed = with_sup(one_for_one, fun test_supervisor_delayed_restart/1). -test_supervisor_delayed_restart(RestartStrategy, PostStartLinkFun) -> - {ok, SupPid} = start_link(RestartStrategy), - ok = PostStartLinkFun(SupPid), +test_supervisor_delayed_restart(SupPid) -> ok = ping_child(SupPid), ok = exit_child(SupPid), timer:sleep(10), @@ -59,12 +55,14 @@ test_supervisor_delayed_restart(RestartStrategy, PostStartLinkFun) -> timeout = ping_child(SupPid), timer:sleep(1010), ok = ping_child(SupPid), - exit(SupPid, shutdown), - rabbit_misc:unlink_and_capture_exit(SupPid), passed. -start_link(RestartStrategy) -> - supervisor2:start_link(?MODULE, [RestartStrategy]). +with_sup(RestartStrategy, Fun) -> + {ok, SupPid} = supervisor2:start_link(?MODULE, [RestartStrategy]), + Res = Fun(SupPid), + exit(SupPid, shutdown), + rabbit_misc:unlink_and_capture_exit(SupPid), + Res. init([RestartStrategy]) -> {ok, {{RestartStrategy, 1, 1}, |