aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2010-11-24 14:29:02 +0100
committerLukas Larsson <[email protected]>2010-12-08 18:07:54 +0100
commit0908ef629325d2aed93f654ea78949205060a013 (patch)
treeabd2cd919b7c294d621eaef95b4aab48d1161f53 /lib/common_test
parente6a27219093c22e6d63025078de9926590816f7c (diff)
downloadotp-0908ef629325d2aed93f654ea78949205060a013.tar.gz
otp-0908ef629325d2aed93f654ea78949205060a013.tar.bz2
otp-0908ef629325d2aed93f654ea78949205060a013.zip
Update all post_*_per_* to also take the Config argument which the *_per_* was called with as an argument.
Diffstat (limited to 'lib/common_test')
-rw-r--r--lib/common_test/src/ct_suite_callback.erl82
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE.erl50
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/empty_scb.erl83
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_post_suite_scb.erl20
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_pre_suite_scb.erl20
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_post_suite_scb.erl20
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_pre_suite_scb.erl20
-rw-r--r--lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/undef_scb.erl20
8 files changed, 159 insertions, 156 deletions
diff --git a/lib/common_test/src/ct_suite_callback.erl b/lib/common_test/src/ct_suite_callback.erl
index dd4fc76c8b..06c7fc3833 100644
--- a/lib/common_test/src/ct_suite_callback.erl
+++ b/lib/common_test/src/ct_suite_callback.erl
@@ -66,15 +66,15 @@ terminate(Callbacks) ->
init_tc(ct_framework, _Func, Args) ->
Args;
init_tc(Mod, init_per_suite, Config) ->
- call(fun call_generic/3, Config, {pre_init_per_suite, Mod});
+ call(fun call_generic/3, Config, [pre_init_per_suite, Mod]);
init_tc(Mod, end_per_suite, Config) ->
- call(fun call_generic/3, Config, {pre_end_per_suite, Mod});
+ call(fun call_generic/3, Config, [pre_end_per_suite, Mod]);
init_tc(_Mod, {init_per_group, GroupName, _}, Config) ->
- call(fun call_generic/3, Config, {pre_init_per_group, GroupName});
+ call(fun call_generic/3, Config, [pre_init_per_group, GroupName]);
init_tc(_Mod, {end_per_group, GroupName, _}, Config) ->
- call(fun call_generic/3, Config, {pre_end_per_group, GroupName});
+ call(fun call_generic/3, Config, [pre_end_per_group, GroupName]);
init_tc(_Mod, TC, Config) ->
- call(fun call_generic/3, Config, {pre_init_per_testcase, TC}).
+ call(fun call_generic/3, Config, [pre_init_per_testcase, TC]).
%% @doc Called as each test case is completed. This includes all configuration
%% tests.
@@ -91,31 +91,31 @@ init_tc(_Mod, TC, Config) ->
end_tc(ct_framework, _Func, _Args, Result, _Return) ->
Result;
-end_tc(Mod, init_per_suite, _Config, _Result, Return) when is_list(Return) ->
- call(fun call_generic/3, Return, {post_init_per_suite, Mod});
-end_tc(Mod, init_per_suite, _Config, Result, _Return) ->
- call(fun call_generic/3, Result, {post_init_per_suite, Mod});
+end_tc(Mod, init_per_suite, Config, _Result, Return) when is_list(Return) ->
+ call(fun call_generic/3, Return, [post_init_per_suite, Mod, Config]);
+end_tc(Mod, init_per_suite, Config, Result, _Return) ->
+ call(fun call_generic/3, Result, [post_init_per_suite, Mod, Config]);
-end_tc(Mod, end_per_suite, _Config, Result, _Return) ->
- call(fun call_generic/3, Result, {post_end_per_suite, Mod});
+end_tc(Mod, end_per_suite, Config, Result, _Return) ->
+ call(fun call_generic/3, Result, [post_end_per_suite, Mod, Config]);
-end_tc(_Mod, {init_per_group, GroupName, _}, _Config, _Result, Return)
+end_tc(_Mod, {init_per_group, GroupName, _}, Config, _Result, Return)
when is_list(Return) ->
- call(fun call_generic/3, Return, {post_init_per_group, GroupName});
-end_tc(_Mod, {init_per_group, GroupName, _}, _Config, Result, _Return) ->
- call(fun call_generic/3, Result, {post_init_per_group, GroupName});
+ call(fun call_generic/3, Return, [post_init_per_group, GroupName, Config]);
+end_tc(_Mod, {init_per_group, GroupName, _}, Config, Result, _Return) ->
+ call(fun call_generic/3, Result, [post_init_per_group, GroupName, Config]);
-end_tc(_Mod, {end_per_group, GroupName, _}, _Config, Result, _Return) ->
- call(fun call_generic/3, Result, {post_end_per_group, GroupName});
+end_tc(_Mod, {end_per_group, GroupName, _}, Config, Result, _Return) ->
+ call(fun call_generic/3, Result, [post_end_per_group, GroupName, Config]);
-end_tc(_Mod, TC, _Config, Result, _Return) ->
- call(fun call_generic/3, Result, {post_end_per_testcase, TC}).
+end_tc(_Mod, TC, Config, Result, _Return) ->
+ call(fun call_generic/3, Result, [post_end_per_testcase, TC, Config]).
on_tc_skip(How, {_Suite, Case, Reason}) ->
- call(fun call_cleanup/3, {How, Reason}, {on_tc_skip, Case}).
+ call(fun call_cleanup/3, {How, Reason}, [on_tc_skip, Case]).
-on_tc_fail(How, {_Suite, Case, Reason}) ->
- call(fun call_cleanup/3, Reason, {on_tc_fail, Case}).
+on_tc_fail(_How, {_Suite, Case, Reason}) ->
+ call(fun call_cleanup/3, Reason, [on_tc_fail, Case]).
%% -------------------------------------------------------------------------
%% Internal Functions
@@ -130,19 +130,15 @@ call_terminate({Mod, State}, _, _) ->
catch_apply(Mod,terminate,[State], ok),
{[],{Mod,State}}.
-call_cleanup({Mod, State}, Reason, {Function, Tag}) ->
- NewState = catch_apply(Mod,Function,[Tag, Reason, State],
+call_cleanup({Mod, State}, Reason, [Function | Args]) ->
+ NewState = catch_apply(Mod,Function, Args ++ [Reason, State],
{Reason,State}),
{Reason, {Mod, NewState}}.
-call_generic({Mod, State}, Config, {Function, undefined}) ->
- {NewConf, NewState} = catch_apply(Mod,Function,[Config, State],
- {Config, State}),
- {NewConf, {Mod, NewState}};
-call_generic({Mod, State}, Config, {Function, Tag}) ->
- {NewConf, NewState} = catch_apply(Mod,Function,[Tag, Config, State],
- {Config,State}),
- {NewConf, {Mod, NewState}}.
+call_generic({Mod, State}, Value, [Function | Args]) ->
+ {NewValue, NewState} = catch_apply(Mod, Function, Args ++ [Value, State],
+ {Value,State}),
+ {NewValue, {Mod, NewState}}.
%% Generic call function
call(Fun, Config, Meta) ->
@@ -191,19 +187,21 @@ remove(_, Else) ->
Else.
%% Translate scopes, i.e. init_per_group,group1 -> end_per_group,group1 etc
-scope({pre_init_per_testcase, TC}) ->
- {post_end_per_testcase, TC};
-scope({pre_init_per_group, GroupName}) ->
- {post_end_per_group, GroupName};
-scope({post_init_per_group, GroupName}) ->
- {post_end_per_group, GroupName};
-scope({pre_init_per_suite, SuiteName}) ->
- {post_end_per_suite, SuiteName};
-scope({post_init_per_suite, SuiteName}) ->
- {post_end_per_suite, SuiteName};
+scope([pre_init_per_testcase, TC|_]) ->
+ [post_end_per_testcase, TC];
+scope([pre_init_per_group, GroupName|_]) ->
+ [post_end_per_group, GroupName];
+scope([post_init_per_group, GroupName|_]) ->
+ [post_end_per_group, GroupName];
+scope([pre_init_per_suite, SuiteName|_]) ->
+ [post_end_per_suite, SuiteName];
+scope([post_init_per_suite, SuiteName|_]) ->
+ [post_end_per_suite, SuiteName];
scope(init) ->
none.
+terminate_if_scope_ends(CBId, [Function,Tag|T], CBs) when T =/= [] ->
+ terminate_if_scope_ends(CBId,[Function,Tag],CBs);
terminate_if_scope_ends(CBId, Function, CBs) ->
case lists:keyfind(CBId, 1, CBs) of
{CBId, Function, _ModState} = CB ->
diff --git a/lib/common_test/test/ct_suite_callback_SUITE.erl b/lib/common_test/test/ct_suite_callback_SUITE.erl
index b6af8e0c2a..3a7727120d 100644
--- a/lib/common_test/test/ct_suite_callback_SUITE.erl
+++ b/lib/common_test/test/ct_suite_callback_SUITE.erl
@@ -191,18 +191,18 @@ test_events(one_empty_scb) ->
{?eh,scb,{empty_scb,pre_init_per_suite,
[ct_scb_empty_SUITE,'$proplist',[]]}},
{?eh,scb,{empty_scb,post_init_per_suite,
- [ct_scb_empty_SUITE,'$proplist',[]]}},
+ [ct_scb_empty_SUITE,'$proplist','$proplist',[]]}},
{?eh,tc_done,{ct_scb_empty_SUITE,init_per_suite,ok}},
{?eh,tc_start,{ct_scb_empty_SUITE,test_case}},
{?eh,scb,{empty_scb,pre_init_per_testcase,[test_case,'$proplist',[]]}},
- {?eh,scb,{empty_scb,post_end_per_testcase,[test_case,'_',[]]}},
+ {?eh,scb,{empty_scb,post_end_per_testcase,[test_case,'$proplist','_',[]]}},
{?eh,tc_done,{ct_scb_empty_SUITE,test_case,ok}},
{?eh,tc_start,{ct_scb_empty_SUITE,end_per_suite}},
{?eh,scb,{empty_scb,pre_end_per_suite,
[ct_scb_empty_SUITE,'$proplist',[]]}},
- {?eh,scb,{empty_scb,post_end_per_suite,[ct_scb_empty_SUITE,'_',[]]}},
+ {?eh,scb,{empty_scb,post_end_per_suite,[ct_scb_empty_SUITE,'$proplist','_',[]]}},
{?eh,tc_done,{ct_scb_empty_SUITE,end_per_suite,ok}},
{?eh,test_done,{'DEF','STOP_TIME'}},
{?eh,scb,{empty_scb,terminate,[[]]}},
@@ -218,22 +218,22 @@ test_events(two_empty_scb) ->
{?eh,tc_start,{ct_scb_empty_SUITE,init_per_suite}},
{?eh,scb,{'_',pre_init_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}},
{?eh,scb,{'_',pre_init_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}},
- {?eh,scb,{'_',post_init_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}},
- {?eh,scb,{'_',post_init_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}},
+ {?eh,scb,{'_',post_init_per_suite,[ct_scb_empty_SUITE,'$proplist','$proplist',[]]}},
+ {?eh,scb,{'_',post_init_per_suite,[ct_scb_empty_SUITE,'$proplist','$proplist',[]]}},
{?eh,tc_done,{ct_scb_empty_SUITE,init_per_suite,ok}},
{?eh,tc_start,{ct_scb_empty_SUITE,test_case}},
{?eh,scb,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}},
{?eh,scb,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}},
- {?eh,scb,{'_',post_end_per_testcase,[test_case,ok,[]]}},
- {?eh,scb,{'_',post_end_per_testcase,[test_case,ok,[]]}},
+ {?eh,scb,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}},
+ {?eh,scb,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}},
{?eh,tc_done,{ct_scb_empty_SUITE,test_case,ok}},
{?eh,tc_start,{ct_scb_empty_SUITE,end_per_suite}},
{?eh,scb,{'_',pre_end_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}},
{?eh,scb,{'_',pre_end_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}},
- {?eh,scb,{'_',post_end_per_suite,[ct_scb_empty_SUITE,'_',[]]}},
- {?eh,scb,{'_',post_end_per_suite,[ct_scb_empty_SUITE,'_',[]]}},
+ {?eh,scb,{'_',post_end_per_suite,[ct_scb_empty_SUITE,'$proplist','_',[]]}},
+ {?eh,scb,{'_',post_end_per_suite,[ct_scb_empty_SUITE,'$proplist','_',[]]}},
{?eh,tc_done,{ct_scb_empty_SUITE,end_per_suite,ok}},
{?eh,test_done,{'DEF','STOP_TIME'}},
{?eh,scb,{'_',terminate,[[]]}},
@@ -282,17 +282,17 @@ test_events(minimal_and_maximal_scb) ->
{?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
{?eh,tc_start,{ct_scb_empty_SUITE,init_per_suite}},
{?eh,scb,{'_',pre_init_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}},
- {?eh,scb,{'_',post_init_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}},
+ {?eh,scb,{'_',post_init_per_suite,[ct_scb_empty_SUITE,'$proplist','$proplist',[]]}},
{?eh,tc_done,{ct_scb_empty_SUITE,init_per_suite,ok}},
{?eh,tc_start,{ct_scb_empty_SUITE,test_case}},
{?eh,scb,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}},
- {?eh,scb,{'_',post_end_per_testcase,[test_case,ok,[]]}},
+ {?eh,scb,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}},
{?eh,tc_done,{ct_scb_empty_SUITE,test_case,ok}},
{?eh,tc_start,{ct_scb_empty_SUITE,end_per_suite}},
{?eh,scb,{'_',pre_end_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}},
- {?eh,scb,{'_',post_end_per_suite,[ct_scb_empty_SUITE,'_',[]]}},
+ {?eh,scb,{'_',post_end_per_suite,[ct_scb_empty_SUITE,'$proplist','_',[]]}},
{?eh,tc_done,{ct_scb_empty_SUITE,end_per_suite,ok}},
{?eh,test_done,{'DEF','STOP_TIME'}},
{?eh,scb,{'_',terminate,[[]]}},
@@ -330,18 +330,18 @@ test_events(scope_per_suite_scb) ->
{?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
{?eh,tc_start,{ct_scope_per_suite_scb_SUITE,init_per_suite}},
{?eh,scb,{'_',init,[[]]}},
- {?eh,scb,{'_',post_init_per_suite,[ct_scope_per_suite_scb_SUITE,'$proplist',[]]}},
+ {?eh,scb,{'_',post_init_per_suite,[ct_scope_per_suite_scb_SUITE,'$proplist','$proplist',[]]}},
{?eh,tc_done,{ct_scope_per_suite_scb_SUITE,init_per_suite,ok}},
{?eh,tc_start,{ct_scope_per_suite_scb_SUITE,test_case}},
{?eh,scb,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}},
- {?eh,scb,{'_',post_end_per_testcase,[test_case,ok,[]]}},
+ {?eh,scb,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}},
{?eh,tc_done,{ct_scope_per_suite_scb_SUITE,test_case,ok}},
{?eh,tc_start,{ct_scope_per_suite_scb_SUITE,end_per_suite}},
{?eh,scb,{'_',pre_end_per_suite,
[ct_scope_per_suite_scb_SUITE,'$proplist',[]]}},
- {?eh,scb,{'_',post_end_per_suite,[ct_scope_per_suite_scb_SUITE,'_',[]]}},
+ {?eh,scb,{'_',post_end_per_suite,[ct_scope_per_suite_scb_SUITE,'$proplist','_',[]]}},
{?eh,scb,{'_',terminate,[[]]}},
{?eh,tc_done,{ct_scope_per_suite_scb_SUITE,end_per_suite,ok}},
{?eh,test_done,{'DEF','STOP_TIME'}},
@@ -355,17 +355,17 @@ test_events(scope_suite_scb) ->
{?eh,tc_start,{ct_scope_suite_scb_SUITE,init_per_suite}},
{?eh,scb,{'_',init,[[]]}},
{?eh,scb,{'_',pre_init_per_suite,[ct_scope_suite_scb_SUITE,'$proplist',[]]}},
- {?eh,scb,{'_',post_init_per_suite,[ct_scope_suite_scb_SUITE,'$proplist',[]]}},
+ {?eh,scb,{'_',post_init_per_suite,[ct_scope_suite_scb_SUITE,'$proplist','$proplist',[]]}},
{?eh,tc_done,{ct_scope_suite_scb_SUITE,init_per_suite,ok}},
{?eh,tc_start,{ct_scope_suite_scb_SUITE,test_case}},
{?eh,scb,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}},
- {?eh,scb,{'_',post_end_per_testcase,[test_case,ok,[]]}},
+ {?eh,scb,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}},
{?eh,tc_done,{ct_scope_suite_scb_SUITE,test_case,ok}},
{?eh,tc_start,{ct_scope_suite_scb_SUITE,end_per_suite}},
{?eh,scb,{'_',pre_end_per_suite,[ct_scope_suite_scb_SUITE,'$proplist',[]]}},
- {?eh,scb,{'_',post_end_per_suite,[ct_scope_suite_scb_SUITE,'_',[]]}},
+ {?eh,scb,{'_',post_end_per_suite,[ct_scope_suite_scb_SUITE,'$proplist','_',[]]}},
{?eh,scb,{'_',terminate,[[]]}},
{?eh,tc_done,{ct_scope_suite_scb_SUITE,end_per_suite,ok}},
{?eh,test_done,{'DEF','STOP_TIME'}},
@@ -381,17 +381,17 @@ test_events(scope_per_group_scb) ->
[{?eh,tc_start,{ct_scope_per_group_scb_SUITE,{init_per_group,group1,[]}}},
{?eh,scb,{'_',init,[[]]}},
- {?eh,scb,{'_',post_init_per_group,[group1,'$proplist',[]]}},
+ {?eh,scb,{'_',post_init_per_group,[group1,'$proplist','$proplist',[]]}},
{?eh,tc_done,{ct_scope_per_group_scb_SUITE,{init_per_group,group1,[]},ok}},
{?eh,tc_start,{ct_scope_per_group_scb_SUITE,test_case}},
{?eh,scb,{'_',pre_init_per_testcase,[test_case,'$proplist',[]]}},
- {?eh,scb,{'_',post_end_per_testcase,[test_case,ok,[]]}},
+ {?eh,scb,{'_',post_end_per_testcase,[test_case,'$proplist',ok,[]]}},
{?eh,tc_done,{ct_scope_per_group_scb_SUITE,test_case,ok}},
{?eh,tc_start,{ct_scope_per_group_scb_SUITE,{end_per_group,group1,[]}}},
{?eh,scb,{'_',pre_end_per_group,[group1,'$proplist',[]]}},
- {?eh,scb,{'_',post_end_per_group,[group1,'_',[]]}},
+ {?eh,scb,{'_',post_end_per_group,[group1,'$proplist','_',[]]}},
{?eh,scb,{'_',terminate,[[]]}},
{?eh,tc_done,{ct_scope_per_group_scb_SUITE,{end_per_group,group1,[]},ok}}],
@@ -410,7 +410,7 @@ test_events(fail_pre_suite_scb) ->
{?eh,tc_start,{ct_scb_empty_SUITE,init_per_suite}},
{?eh,scb,{'_',pre_init_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}},
- {?eh,scb,{'_',post_init_per_suite,[ct_scb_empty_SUITE,
+ {?eh,scb,{'_',post_init_per_suite,[ct_scb_empty_SUITE,'$proplist',
{error,"Test failure"},[]]}},
{?eh,tc_done,{ct_scb_empty_SUITE,init_per_suite,
{failed, {error,"Test failure"}}}},
@@ -448,7 +448,7 @@ test_events(fail_post_suite_scb) ->
{?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
{?eh,tc_start,{ct_scb_empty_SUITE,init_per_suite}},
{?eh,scb,{'_',pre_init_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}},
- {?eh,scb,{'_',post_init_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}},
+ {?eh,scb,{'_',post_init_per_suite,[ct_scb_empty_SUITE,'$proplist','$proplist',[]]}},
{?eh,tc_done,{ct_scb_empty_SUITE,init_per_suite,
{failed,{error,"Test failure"}}}},
{?eh,scb,{'_',on_tc_fail,[init_per_suite, {failed,"Test failure"}, []]}},
@@ -475,7 +475,7 @@ test_events(skip_pre_suite_scb) ->
{?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}},
{?eh,tc_start,{ct_scb_empty_SUITE,init_per_suite}},
{?eh,scb,{'_',pre_init_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}},
- {?eh,scb,{'_',post_init_per_suite,[ct_scb_empty_SUITE,{skip,"Test skip"},[]]}},
+ {?eh,scb,{'_',post_init_per_suite,[ct_scb_empty_SUITE,'$proplist',{skip,"Test skip"},[]]}},
{?eh,tc_done,{ct_scb_empty_SUITE,init_per_suite,{skipped,"Test skip"}}},
{?eh,scb,{'_',on_tc_skip,
[init_per_suite,{tc_user_skip,{skipped,"Test skip"}},[]]}},
@@ -499,7 +499,7 @@ test_events(skip_post_suite_scb) ->
{?eh,tc_start,{ct_scb_empty_SUITE,init_per_suite}},
{?eh,scb,{'_',pre_init_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}},
- {?eh,scb,{'_',post_init_per_suite,[ct_scb_empty_SUITE,'$proplist',[]]}},
+ {?eh,scb,{'_',post_init_per_suite,[ct_scb_empty_SUITE,'$proplist','$proplist',[]]}},
{?eh,tc_done,{ct_scb_empty_SUITE,init_per_suite,{skipped,"Test skip"}}},
{?eh,scb,{'_',on_tc_skip,
[init_per_suite,{tc_user_skip,{skipped,"Test skip"}},[]]}},
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/empty_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/empty_scb.erl
index 05f6563c45..d9aa1e77e4 100644
--- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/empty_scb.erl
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/empty_scb.erl
@@ -38,17 +38,17 @@
-export([init/1]).
-export([pre_init_per_suite/3]).
--export([post_init_per_suite/3]).
+-export([post_init_per_suite/4]).
-export([pre_end_per_suite/3]).
--export([post_end_per_suite/3]).
+-export([post_end_per_suite/4]).
-export([pre_init_per_group/3]).
--export([post_init_per_group/3]).
+-export([post_init_per_group/4]).
-export([pre_end_per_group/3]).
--export([post_end_per_group/3]).
+-export([post_end_per_group/4]).
-export([pre_init_per_testcase/3]).
--export([post_end_per_testcase/3]).
+-export([post_end_per_testcase/4]).
-export([on_tc_fail/3]).
-export([on_tc_skip/3]).
@@ -95,22 +95,23 @@ pre_init_per_suite(Suite,Config,State) ->
{Config, State}.
%% @doc Called after init_per_suite.
-%% you can change the config in this function.
+%% you can change the return value in this function.
-spec post_init_per_suite(Suite :: atom(),
- Config :: config(),
- State :: #state{}) ->
+ Config :: config(),
+ Return :: config() | skip_or_fail(),
+ State :: #state{}) ->
{config() | skip_or_fail(), NewState :: #state{}}.
-post_init_per_suite(Suite,Config,State) ->
+post_init_per_suite(Suite,Config,Return,State) ->
gen_event:notify(
?CT_EVMGR_REF, #event{ name = scb, node = node(),
data = {?MODULE, post_init_per_suite,
- [Suite,Config,State]}}),
- {Config, State}.
+ [Suite,Config,Return,State]}}),
+ {Return, State}.
-%% @doc Called before end_per_suite. Note that the config cannot be
-%% changed here, only the status of the suite.
+%% @doc Called before end_per_suite. The config/state can be changed here,
+%% though it will only affect the *end_per_suite function.
-spec pre_end_per_suite(Suite :: atom(),
- Config :: config(),
+ Config :: config() | skip_or_fail(),
State :: #state{}) ->
{ok | skip_or_fail(), NewState :: #state{}}.
pre_end_per_suite(Suite,Config,State) ->
@@ -123,15 +124,16 @@ pre_end_per_suite(Suite,Config,State) ->
%% @doc Called after end_per_suite. Note that the config cannot be
%% changed here, only the status of the suite.
-spec post_end_per_suite(Suite :: atom(),
- Config :: config(),
- State :: #state{}) ->
+ Config :: config(),
+ Return :: term(),
+ State :: #state{}) ->
{ok | skip_or_fail(), NewState :: #state{}}.
-post_end_per_suite(Suite,Config,State) ->
+post_end_per_suite(Suite,Config,Return,State) ->
gen_event:notify(
?CT_EVMGR_REF, #event{ name = scb, node = node(),
data = {?MODULE, post_end_per_suite,
- [Suite,Config,State]}}),
- {Config, State}.
+ [Suite,Config,Return,State]}}),
+ {Return, State}.
%% @doc Called before each init_per_group.
%% You can change the config in this function.
@@ -147,23 +149,24 @@ pre_init_per_group(Group,Config,State) ->
{Config, State}.
%% @doc Called after each init_per_group.
-%% You can change the config in this function.
+%% You can change the return value in this function.
-spec post_init_per_group(Group :: atom(),
- Config :: config(),
- State :: #state{}) ->
+ Config :: config(),
+ Return :: config() | skip_or_fail(),
+ State :: #state{}) ->
{config() | skip_or_fail(), NewState :: #state{}}.
-post_init_per_group(Group,Config,State) ->
+post_init_per_group(Group,Config,Return,State) ->
gen_event:notify(
?CT_EVMGR_REF, #event{ name = scb, node = node(),
data = {?MODULE, post_init_per_group,
- [Group,Config,State]}}),
- {Config, State}.
+ [Group,Config,Return,State]}}),
+ {Return, State}.
-%% @doc Called after each end_per_group. Note that the config cannot be
-%% changed here, only the status of the group.
+%% @doc Called after each end_per_group. The config/state can be changed here,
+%% though it will only affect the *end_per_group functions.
-spec pre_end_per_group(Group :: atom(),
- Config :: config(),
- State :: #state{}) ->
+ Config :: config() | skip_or_fail(),
+ State :: #state{}) ->
{ok | skip_or_fail(), NewState :: #state{}}.
pre_end_per_group(Group,Config,State) ->
gen_event:notify(
@@ -175,15 +178,16 @@ pre_end_per_group(Group,Config,State) ->
%% @doc Called after each end_per_group. Note that the config cannot be
%% changed here, only the status of the group.
-spec post_end_per_group(Group :: atom(),
- Config :: config(),
- State :: #state{}) ->
+ Config :: config(),
+ Return :: term(),
+ State :: #state{}) ->
{ok | skip_or_fail(), NewState :: #state{}}.
-post_end_per_group(Group,Config,State) ->
+post_end_per_group(Group,Config,Return,State) ->
gen_event:notify(
?CT_EVMGR_REF, #event{ name = scb, node = node(),
data = {?MODULE, post_end_per_group,
- [Group,Config,State]}}),
- {Config, State}.
+ [Group,Config,Return,State]}}),
+ {Return, State}.
%% @doc Called before each test case.
%% You can change the config in this function.
@@ -201,15 +205,16 @@ pre_init_per_testcase(TC,Config,State) ->
%% @doc Called after each test case. Note that the config cannot be
%% changed here, only the status of the test case.
-spec post_end_per_testcase(TC :: atom(),
- Config :: config(),
- State :: #state{}) ->
+ Config :: config(),
+ Return :: term(),
+ State :: #state{}) ->
{ok | skip_or_fail(), NewState :: #state{}}.
-post_end_per_testcase(TC,Config,State) ->
+post_end_per_testcase(TC,Config,Return,State) ->
gen_event:notify(
?CT_EVMGR_REF, #event{ name = scb, node = node(),
data = {?MODULE, post_end_per_testcase,
- [TC,Config,State]}}),
- {Config, State}.
+ [TC,Config,Return,State]}}),
+ {Return, State}.
%% @doc Called after post_init_per_suite, post_end_per_suite, post_init_per_group,
%% post_end_per_group and post_end_per_tc if the suite, group or test case failed.
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_post_suite_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_post_suite_scb.erl
index 2ba5013652..b3a3a5f94c 100644
--- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_post_suite_scb.erl
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_post_suite_scb.erl
@@ -34,33 +34,33 @@ init(Opts) ->
pre_init_per_suite(Suite, Config, State) ->
empty_scb:pre_init_per_suite(Suite,Config,State).
-post_init_per_suite(Suite,Config,State) ->
- empty_scb:post_init_per_suite(Suite,Config,State),
+post_init_per_suite(Suite,Config,Return,State) ->
+ empty_scb:post_init_per_suite(Suite,Config,Return,State),
{{fail, "Test failure"}, State}.
pre_end_per_suite(Suite,Config,State) ->
empty_scb:pre_end_per_suite(Suite,Config,State).
-post_end_per_suite(Suite,Config,State) ->
- empty_scb:post_end_per_suite(Suite,Config,State).
+post_end_per_suite(Suite,Config,Return,State) ->
+ empty_scb:post_end_per_suite(Suite,Config,Return,State).
pre_init_per_group(Group,Config,State) ->
empty_scb:pre_init_per_group(Group,Config,State).
-post_init_per_group(Group,Config,State) ->
- empty_scb:post_init_per_group(Group,Config,State).
+post_init_per_group(Group,Config,Return,State) ->
+ empty_scb:post_init_per_group(Group,Config,Return,State).
pre_end_per_group(Group,Config,State) ->
empty_scb:pre_end_per_group(Group,Config,State).
-post_end_per_group(Group,Config,State) ->
- empty_scb:post_end_per_group(Group,Config,State).
+post_end_per_group(Group,Config,Return,State) ->
+ empty_scb:post_end_per_group(Group,Config,Return,State).
pre_init_per_testcase(TC,Config,State) ->
empty_scb:pre_init_per_testcase(TC,Config,State).
-post_end_per_testcase(TC,Config,State) ->
- empty_scb:post_end_per_testcase(TC,Config,State).
+post_end_per_testcase(TC,Config,Return,State) ->
+ empty_scb:post_end_per_testcase(TC,Config,Return,State).
on_tc_fail(TC, Reason, State) ->
empty_scb:on_tc_fail(TC,Reason,State).
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_pre_suite_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_pre_suite_scb.erl
index f108624836..d49387ff8c 100644
--- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_pre_suite_scb.erl
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/fail_pre_suite_scb.erl
@@ -35,32 +35,32 @@ pre_init_per_suite(Suite, Config, State) ->
empty_scb:pre_init_per_suite(Suite,Config,State),
{{fail, "Test failure"}, State}.
-post_init_per_suite(Suite,Config,State) ->
- empty_scb:post_init_per_suite(Suite,Config,State).
+post_init_per_suite(Suite,Config,Return,State) ->
+ empty_scb:post_init_per_suite(Suite,Config,Return,State).
pre_end_per_suite(Suite,Config,State) ->
empty_scb:pre_end_per_suite(Suite,Config,State).
-post_end_per_suite(Suite,Config,State) ->
- empty_scb:post_end_per_suite(Suite,Config,State).
+post_end_per_suite(Suite,Config,Return,State) ->
+ empty_scb:post_end_per_suite(Suite,Config,Return,State).
pre_init_per_group(Group,Config,State) ->
empty_scb:pre_init_per_group(Group,Config,State).
-post_init_per_group(Group,Config,State) ->
- empty_scb:post_init_per_group(Group,Config,State).
+post_init_per_group(Group,Config,Return,State) ->
+ empty_scb:post_init_per_group(Group,Config,Return,State).
pre_end_per_group(Group,Config,State) ->
empty_scb:pre_end_per_group(Group,Config,State).
-post_end_per_group(Group,Config,State) ->
- empty_scb:post_end_per_group(Group,Config,State).
+post_end_per_group(Group,Config,Return,State) ->
+ empty_scb:post_end_per_group(Group,Config,Return,State).
pre_init_per_testcase(TC,Config,State) ->
empty_scb:pre_init_per_testcase(TC,Config,State).
-post_end_per_testcase(TC,Config,State) ->
- empty_scb:post_end_per_testcase(TC,Config,State).
+post_end_per_testcase(TC,Config,Return,State) ->
+ empty_scb:post_end_per_testcase(TC,Config,Return,State).
on_tc_fail(TC, Reason, State) ->
empty_scb:on_tc_fail(TC,Reason,State).
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_post_suite_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_post_suite_scb.erl
index 5462e34175..a2e0578814 100644
--- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_post_suite_scb.erl
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_post_suite_scb.erl
@@ -34,33 +34,33 @@ init(Opts) ->
pre_init_per_suite(Suite, Config, State) ->
empty_scb:pre_init_per_suite(Suite,Config,State).
-post_init_per_suite(Suite,Config,State) ->
- empty_scb:post_init_per_suite(Suite,Config,State),
+post_init_per_suite(Suite,Config,Return,State) ->
+ empty_scb:post_init_per_suite(Suite,Config,Return,State),
{{skip, "Test skip"}, State}.
pre_end_per_suite(Suite,Config,State) ->
empty_scb:pre_end_per_suite(Suite,Config,State).
-post_end_per_suite(Suite,Config,State) ->
- empty_scb:post_end_per_suite(Suite,Config,State).
+post_end_per_suite(Suite,Config,Return,State) ->
+ empty_scb:post_end_per_suite(Suite,Config,Return,State).
pre_init_per_group(Group,Config,State) ->
empty_scb:pre_init_per_group(Group,Config,State).
-post_init_per_group(Group,Config,State) ->
- empty_scb:post_init_per_group(Group,Config,State).
+post_init_per_group(Group,Config,Return,State) ->
+ empty_scb:post_init_per_group(Group,Config,Return,State).
pre_end_per_group(Group,Config,State) ->
empty_scb:pre_end_per_group(Group,Config,State).
-post_end_per_group(Group,Config,State) ->
- empty_scb:post_end_per_group(Group,Config,State).
+post_end_per_group(Group,Config,Return,State) ->
+ empty_scb:post_end_per_group(Group,Config,Return,State).
pre_init_per_testcase(TC,Config,State) ->
empty_scb:pre_init_per_testcase(TC,Config,State).
-post_end_per_testcase(TC,Config,State) ->
- empty_scb:post_end_per_testcase(TC,Config,State).
+post_end_per_testcase(TC,Config,Return,State) ->
+ empty_scb:post_end_per_testcase(TC,Config,Return,State).
on_tc_fail(TC, Reason, State) ->
empty_scb:on_tc_fail(TC,Reason,State).
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_pre_suite_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_pre_suite_scb.erl
index 006ae4a90f..4a0725ce2f 100644
--- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_pre_suite_scb.erl
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/skip_pre_suite_scb.erl
@@ -36,32 +36,32 @@ pre_init_per_suite(Suite, Config, State) ->
empty_scb:pre_init_per_suite(Suite,Config,State),
{{skip, "Test skip"}, State}.
-post_init_per_suite(Suite,Config,State) ->
- empty_scb:post_init_per_suite(Suite,Config,State).
+post_init_per_suite(Suite,Config,Return,State) ->
+ empty_scb:post_init_per_suite(Suite,Config,Return,State).
pre_end_per_suite(Suite,Config,State) ->
empty_scb:pre_end_per_suite(Suite,Config,State).
-post_end_per_suite(Suite,Config,State) ->
- empty_scb:post_end_per_suite(Suite,Config,State).
+post_end_per_suite(Suite,Config,Return,State) ->
+ empty_scb:post_end_per_suite(Suite,Config,Return,State).
pre_init_per_group(Group,Config,State) ->
empty_scb:pre_init_per_group(Group,Config,State).
-post_init_per_group(Group,Config,State) ->
- empty_scb:post_init_per_group(Group,Config,State).
+post_init_per_group(Group,Config,Return,State) ->
+ empty_scb:post_init_per_group(Group,Config,Return,State).
pre_end_per_group(Group,Config,State) ->
empty_scb:pre_end_per_group(Group,Config,State).
-post_end_per_group(Group,Config,State) ->
- empty_scb:post_end_per_group(Group,Config,State).
+post_end_per_group(Group,Config,Return,State) ->
+ empty_scb:post_end_per_group(Group,Config,Return,State).
pre_init_per_testcase(TC,Config,State) ->
empty_scb:pre_init_per_testcase(TC,Config,State).
-post_end_per_testcase(TC,Config,State) ->
- empty_scb:post_end_per_testcase(TC,Config,State).
+post_end_per_testcase(TC,Config,Return,State) ->
+ empty_scb:post_end_per_testcase(TC,Config,Return,State).
on_tc_fail(TC, Reason, State) ->
empty_scb:on_tc_fail(TC,Reason,State).
diff --git a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/undef_scb.erl b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/undef_scb.erl
index 80d0f10415..9479f9d937 100644
--- a/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/undef_scb.erl
+++ b/lib/common_test/test/ct_suite_callback_SUITE_data/scb/tests/undef_scb.erl
@@ -34,32 +34,32 @@ init(Opts) ->
pre_init_per_suite(_Suite, _Config, _State) ->
lists:flaten([1,2,[3,4]]).
-post_init_per_suite(Suite,Config,State) ->
- empty_scb:post_init_per_suite(Suite,Config,State).
+post_init_per_suite(Suite,Config,Return,State) ->
+ empty_scb:post_init_per_suite(Suite,Config,Return,State).
pre_end_per_suite(Suite,Config,State) ->
empty_scb:pre_end_per_suite(Suite,Config,State).
-post_end_per_suite(Suite,Config,State) ->
- empty_scb:post_end_per_suite(Suite,Config,State).
+post_end_per_suite(Suite,Config,Return,State) ->
+ empty_scb:post_end_per_suite(Suite,Config,Return,State).
pre_init_per_group(Group,Config,State) ->
empty_scb:pre_init_per_group(Group,Config,State).
-post_init_per_group(Group,Config,State) ->
- empty_scb:post_init_per_group(Group,Config,State).
+post_init_per_group(Group,Config,Return,State) ->
+ empty_scb:post_init_per_group(Group,Config,Return,State).
pre_end_per_group(Group,Config,State) ->
empty_scb:pre_end_per_group(Group,Config,State).
-post_end_per_group(Group,Config,State) ->
- empty_scb:post_end_per_group(Group,Config,State).
+post_end_per_group(Group,Config,Return,State) ->
+ empty_scb:post_end_per_group(Group,Config,Return,State).
pre_init_per_testcase(TC,Config,State) ->
empty_scb:pre_init_per_testcase(TC,Config,State).
-post_end_per_testcase(TC,Config,State) ->
- empty_scb:post_end_per_testcase(TC,Config,State).
+post_end_per_testcase(TC,Config,Return,State) ->
+ empty_scb:post_end_per_testcase(TC,Config,Return,State).
on_tc_fail(TC, Reason, State) ->
empty_scb:on_tc_fail(TC,Reason,State).