From 18f8352c8fb8f08a8586b89e97f32852be8f937f Mon Sep 17 00:00:00 2001 From: Simon MacMullen Date: Thu, 1 Dec 2011 16:54:54 +0000 Subject: Failing test. --- src/mirrored_supervisor_tests.erl | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/mirrored_supervisor_tests.erl b/src/mirrored_supervisor_tests.erl index b8d52ae8..0ec50ce8 100644 --- a/src/mirrored_supervisor_tests.erl +++ b/src/mirrored_supervisor_tests.erl @@ -197,6 +197,22 @@ test_ignore() -> {sup, fake_strategy_for_ignore, []}), passed. +test_startup_failure() -> + [test_startup_failure(F) || F <- [error, exit]], + passed. + +test_startup_failure(Fail) -> + process_flag(trap_exit, true), + ?MS:start_link(get_group(group), ?MODULE, + {sup, one_for_one, [childspec(Fail)]}), + process_flag(trap_exit, false), + receive + {'EXIT', _, shutdown} -> + ok + after 1000 -> + exit({did_not_exit, Fail}) + end. + %% --------------------------------------------------------------------------- with_sups(Fun, Sups) -> @@ -230,6 +246,12 @@ start_sup0(Name, Group, ChildSpecs) -> childspec(Id) -> {Id, {?MODULE, start_gs, [Id]}, transient, 16#ffffffff, worker, [?MODULE]}. +start_gs(error) -> + {error, foo}; + +start_gs(exit) -> + {exit, foo}; + start_gs(Id) -> gen_server:start_link({local, Id}, ?MODULE, server, []). @@ -281,6 +303,12 @@ kill_wait(Pid) -> init({sup, fake_strategy_for_ignore, _ChildSpecs}) -> ignore; +init({sup, fake_strategy_for_startup_error, _ChildSpecs}) -> + {error, foo}; + +init({sup, fake_strategy_for_startup_exit, _ChildSpecs}) -> + exit(foo); + init({sup, Strategy, ChildSpecs}) -> {ok, {{Strategy, 0, 1}, ChildSpecs}}; -- cgit v1.2.1