From 187cf0a2a5cb5cc5f94e2b9bb07b03955ad6eb4d Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Fri, 29 Jul 2011 11:51:15 +0200 Subject: Update the return from init/2 to be {ok, NewState} or {ok,NewState,Priority} instead of NewState. NewState can still be returned, but is only kept for backward compatability reasons. --- lib/common_test/src/ct_hooks.erl | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/common_test/src/ct_hooks.erl') diff --git a/lib/common_test/src/ct_hooks.erl b/lib/common_test/src/ct_hooks.erl index bbadb657e1..9b288ad168 100644 --- a/lib/common_test/src/ct_hooks.erl +++ b/lib/common_test/src/ct_hooks.erl @@ -135,10 +135,19 @@ call_id(#ct_hook_config{ module = Mod, opts = Opts} = Hook, Config, Scope) -> Id = catch_apply(Mod,id,[Opts], make_ref()), {Config, Hook#ct_hook_config{ id = Id, scope = scope(Scope)}}. -call_init(#ct_hook_config{ module = Mod, opts = Opts, id = Id} = Hook, +call_init(#ct_hook_config{ module = Mod, opts = Opts, id = Id, prio = P} = Hook, Config,_Meta) -> - NewState = Mod:init(Id, Opts), - {Config, Hook#ct_hook_config{ state = NewState } }. + case Mod:init(Id, Opts) of + {ok, NewState} -> + {Config, Hook#ct_hook_config{ state = NewState } }; + {ok, NewState, Prio} when P =:= undefined -> + %% Only set prio if not already set when installing hook + {Config, Hook#ct_hook_config{ state = NewState, prio = Prio } }; + {ok, NewState, _} -> + {Config, Hook#ct_hook_config{ state = NewState } }; + NewState -> %% Keep for backward compatability reasons + {Config, Hook#ct_hook_config{ state = NewState } } + end. call_terminate(#ct_hook_config{ module = Mod, state = State} = Hook, _, _) -> catch_apply(Mod,terminate,[State], ok), -- cgit v1.2.3