aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/common_test/src/ct_framework.erl22
-rw-r--r--lib/common_test/src/ct_suite_callback.erl30
-rw-r--r--lib/test_server/src/test_server.erl34
-rw-r--r--lib/test_server/src/test_server_ctrl.erl2
4 files changed, 51 insertions, 37 deletions
diff --git a/lib/common_test/src/ct_framework.erl b/lib/common_test/src/ct_framework.erl
index f7c07a5374..dbf367e4d8 100644
--- a/lib/common_test/src/ct_framework.erl
+++ b/lib/common_test/src/ct_framework.erl
@@ -484,21 +484,27 @@ end_tc(Mod,Func,TCPid,Result,Args,Return) ->
case get('$test_server_framework_test') of
undefined ->
- FinalResult = ct_suite_callback:end_tc(
- Mod, FuncSpec, Args, Result, Return),
+ {FinalResult,FinalNotify} =
+ case ct_suite_callback:end_tc(
+ Mod, FuncSpec, Args, Result, Return) of
+ '$ct_no_change' ->
+ {FinalResult = ok,Result};
+ FinalResult ->
+ {FinalResult,FinalResult}
+ end,
% send sync notification so that event handlers may print
% in the log file before it gets closed
ct_event:sync_notify(#event{name=tc_done,
node=node(),
data={Mod,FuncSpec,
- tag_scb(FinalResult)}});
+ tag_scb(FinalNotify)}});
Fun ->
% send sync notification so that event handlers may print
% in the log file before it gets closed
ct_event:sync_notify(#event{name=tc_done,
node=node(),
data={Mod,FuncSpec,tag(Result)}}),
- FinalResult = Fun(end_tc, ok)
+ FinalResult = Fun(end_tc, Return)
end,
@@ -521,13 +527,7 @@ end_tc(Mod,Func,TCPid,Result,Args,Return) ->
_ ->
ok
end,
- case FinalResult of
- Result ->
- ok;
- _Else ->
- FinalResult
- end.
-
+ FinalResult.
%% {error,Reason} | {skip,Reason} | {timetrap_timeout,TVal} |
%% {testcase_aborted,Reason} | testcase_aborted_or_killed |
diff --git a/lib/common_test/src/ct_suite_callback.erl b/lib/common_test/src/ct_suite_callback.erl
index 06c7fc3833..4973ed685c 100644
--- a/lib/common_test/src/ct_suite_callback.erl
+++ b/lib/common_test/src/ct_suite_callback.erl
@@ -91,25 +91,25 @@ 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, 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, init_per_suite, Config, Result, Return) ->
+ call(fun call_generic/3, Return, [post_init_per_suite, Mod, Config],
+ '$ct_no_change');
end_tc(Mod, end_per_suite, Config, Result, _Return) ->
- call(fun call_generic/3, Result, [post_end_per_suite, Mod, Config]);
+ call(fun call_generic/3, Result, [post_end_per_suite, Mod, Config],
+ '$ct_no_change');
-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, 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, {init_per_group, GroupName, _}, Config, Result, Return) ->
+ call(fun call_generic/3, Return, [post_init_per_group, GroupName, Config],
+ '$ct_no_change');
end_tc(_Mod, {end_per_group, GroupName, _}, Config, Result, _Return) ->
- call(fun call_generic/3, Result, [post_end_per_group, GroupName, Config]);
+ call(fun call_generic/3, Result, [post_end_per_group, GroupName, Config],
+ '$ct_no_change');
end_tc(_Mod, TC, Config, Result, _Return) ->
- call(fun call_generic/3, Result, [post_end_per_testcase, TC, Config]).
+ call(fun call_generic/3, Result, [post_end_per_testcase, TC, Config],
+ '$ct_no_change').
on_tc_skip(How, {_Suite, Case, Reason}) ->
call(fun call_cleanup/3, {How, Reason}, [on_tc_skip, Case]).
@@ -146,6 +146,12 @@ call(Fun, Config, Meta) ->
call([{CBId,Fun} || {CBId,_, _} <- CBs] ++ get_new_callbacks(Config, Fun),
remove(?config_name,Config), Meta, CBs).
+call(Fun, Config, Meta, NoChangeRet) when is_function(Fun) ->
+ case call(Fun,Config,Meta) of
+ Config -> NoChangeRet;
+ NewReturn -> NewReturn
+ end;
+
call([{CB, call_init, NextFun} | Rest], Config, Meta, CBs) ->
try
{Config, {NewId, _, {Mod,_State}} = NewCB} = call_init(CB, Config, Meta),
diff --git a/lib/test_server/src/test_server.erl b/lib/test_server/src/test_server.erl
index daee278368..13ff02cc6c 100644
--- a/lib/test_server/src/test_server.erl
+++ b/lib/test_server/src/test_server.erl
@@ -1068,20 +1068,23 @@ run_test_case_eval(Mod, Func, Args0, Name, Ref, RunInit,
{ok,Args} ->
run_test_case_eval1(Mod, Func, Args, Name, RunInit, TCCallback);
Error = {error,_Reason} ->
- do_end_tc_call(Mod,Func,{Error,Args0}, Error),
- {{0,{skip,{failed,Error}}},{Mod,Func},[]};
+ NewResult = do_end_tc_call(Mod,Func,{Error,Args0},
+ {skip,{failed,Error}}),
+ {{0,NewResult},{Mod,Func},[]};
{fail,Reason} ->
[Conf] = Args0,
Conf1 = [{tc_status,{failed,Reason}} | Conf],
fw_error_notify(Mod, Func, Conf, Reason),
- do_end_tc_call(Mod,Func, {{error,Reason},[Conf1]},{fail, Reason}),
- {{0,{failed,Reason}},{Mod,Func},[]};
+ NewResult = do_end_tc_call(Mod,Func, {{error,Reason},[Conf1]},
+ {fail, Reason}),
+ {{0,NewResult},{Mod,Func},[]};
Skip = {skip,_Reason} ->
- do_end_tc_call(Mod,Func,{Skip,Args0},Skip),
- {{0,Skip},{Mod,Func},[]};
+ NewResult = do_end_tc_call(Mod,Func,{Skip,Args0},Skip),
+ {{0,NewResult},{Mod,Func},[]};
{auto_skip,Reason} ->
- do_end_tc_call(Mod, Func, {{skip,Reason},Args0}, {auto_skip, Reason}),
- {{0,{skip,{fw_auto_skip,Reason}}},{Mod,Func},[]}
+ NewResult = do_end_tc_call(Mod, Func, {{skip,Reason},Args0},
+ {skip, {fw_auto_skip,Reason}}),
+ {{0,NewResult},{Mod,Func},[]}
end,
exit({Ref,Time,Value,Loc,Opts}).
@@ -1187,7 +1190,12 @@ do_end_tc_call(M,F,Res,Return) ->
{fail,FWReason} ->
{failed,FWReason};
ok ->
- Return;
+ case Return of
+ {fail,Reason} ->
+ {failed,Reason};
+ Return ->
+ Return
+ end;
NewReturn ->
NewReturn
end;
@@ -1231,8 +1239,8 @@ process_return_val1([Failed={E,TCError}|_], M,F,A=[Args], Loc, _, SaveOpts)
[[{tc_status,{failed,TCError}}|Args]]}, Failed) of
{failed,FWReason} ->
{{failed,FWReason},SaveOpts};
- _ ->
- {Failed,SaveOpts}
+ NewReturn ->
+ {NewReturn,SaveOpts}
end;
process_return_val1([SaveCfg={save_config,_}|Opts], M,F,[Args], Loc, Final, SaveOpts) ->
process_return_val1(Opts, M,F,[[SaveCfg|Args]], Loc, Final, SaveOpts);
@@ -1249,8 +1257,8 @@ process_return_val1([], M,F,A, _Loc, Final, SaveOpts) ->
case do_end_tc_call(M,F,{Final,A}, Final) of
{failed,FWReason} ->
{{failed,FWReason},SaveOpts};
- _ ->
- {Final,lists:reverse(SaveOpts)}
+ NewReturn ->
+ {NewReturn,lists:reverse(SaveOpts)}
end.
user_callback(undefined, _, _, _, Args) ->
diff --git a/lib/test_server/src/test_server_ctrl.erl b/lib/test_server/src/test_server_ctrl.erl
index 1dc5646184..977a2b1785 100644
--- a/lib/test_server/src/test_server_ctrl.erl
+++ b/lib/test_server/src/test_server_ctrl.erl
@@ -3552,7 +3552,7 @@ run_test_case1(Ref, Num, Mod, Func, Args, RunInit, Where,
{_,{'EXIT',Reason}} ->
progress(failed, Num, Mod, Func, Loc, Reason,
Time, Comment, Style);
- {_, {failed, Reason}} ->
+ {_, {Fail, Reason}} when Fail =:= fail; Fail =:= failed ->
progress(failed, Num, Mod, Func, Loc, Reason,
Time, Comment, Style);
{_, {Skip, Reason}} when Skip==skip; Skip==skipped ->