diff options
author | Lukas Larsson <[email protected]> | 2011-07-29 11:51:15 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2011-08-31 10:51:24 +0200 |
commit | 187cf0a2a5cb5cc5f94e2b9bb07b03955ad6eb4d (patch) | |
tree | b0ae8a9f24910ea49928d35ebf474c596d200ac6 /lib/common_test/src/ct_hooks.erl | |
parent | 6b9f8b54324891f2d7fed236cb2860896215d755 (diff) | |
download | otp-187cf0a2a5cb5cc5f94e2b9bb07b03955ad6eb4d.tar.gz otp-187cf0a2a5cb5cc5f94e2b9bb07b03955ad6eb4d.tar.bz2 otp-187cf0a2a5cb5cc5f94e2b9bb07b03955ad6eb4d.zip |
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.
Diffstat (limited to 'lib/common_test/src/ct_hooks.erl')
-rw-r--r-- | lib/common_test/src/ct_hooks.erl | 15 |
1 files changed, 12 insertions, 3 deletions
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), |