From fe8521bf93994a1d0d2021099f3a99473e1d3731 Mon Sep 17 00:00:00 2001 From: Siri Hansen Date: Tue, 4 Jun 2019 14:37:12 +0200 Subject: [ct] Fix bug where Hook:terminate/1 was called before Hook:init/2 This problem was introduced with commit acd87425acf7705328b01aa8f0a804207ffe4790, when the new hook function post_groups/2 and post_all/3 were added. --- lib/common_test/src/ct_hooks.erl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib/common_test/src') diff --git a/lib/common_test/src/ct_hooks.erl b/lib/common_test/src/ct_hooks.erl index 903710963c..dc189c3000 100644 --- a/lib/common_test/src/ct_hooks.erl +++ b/lib/common_test/src/ct_hooks.erl @@ -373,7 +373,16 @@ terminate_if_scope_ends(HookId, Function0, Hooks) -> Function = strip_config(Function0), case lists:keyfind(HookId, #ct_hook_config.id, Hooks) of #ct_hook_config{ id = HookId, scope = Function} = Hook -> - terminate([Hook]), + case Function of + [AllOrGroup,_] when AllOrGroup=:=post_all; + AllOrGroup=:=post_groups -> + %% The scope only contains one function (post_all + %% or post_groups), and init has not been called, + %% so skip terminate as well. + ok; + _ -> + terminate([Hook]) + end, lists:keydelete(HookId, #ct_hook_config.id, Hooks); _ -> Hooks -- cgit v1.2.3