aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common_test/src')
-rw-r--r--lib/common_test/src/ct_framework.erl20
-rw-r--r--lib/common_test/src/ct_suite_callback.erl13
2 files changed, 30 insertions, 3 deletions
diff --git a/lib/common_test/src/ct_framework.erl b/lib/common_test/src/ct_framework.erl
index 9b749523e8..f7c07a5374 100644
--- a/lib/common_test/src/ct_framework.erl
+++ b/lib/common_test/src/ct_framework.erl
@@ -546,7 +546,7 @@ tag(Other) ->
tag_scb({STag,Reason}) when STag == skip; STag == skipped ->
{skipped,Reason};
tag_scb({fail, Reason}) ->
- {failed, Reason};
+ {failed, {error,Reason}};
tag_scb(E = {ETag,_}) when ETag == error; ETag == 'EXIT';
ETag == timetrap_timeout;
ETag == testcase_aborted ->
@@ -1184,6 +1184,18 @@ report(What,Data) ->
ok;
tc_done ->
{_Suite,Case,Result} = Data,
+ case Result of
+ {failed, _} ->
+ ct_suite_callback:on_tc_fail(What, Data);
+ {skipped,{failed,{_,init_per_testcase,_}}} ->
+ ct_suite_callback:on_tc_skip(tc_auto_skip, Data);
+ {skipped,{require_failed,_}} ->
+ ct_suite_callback:on_tc_skip(tc_auto_skip, Data);
+ {skipped,_} ->
+ ct_suite_callback:on_tc_skip(tc_user_skip, Data);
+ _Else ->
+ ok
+ end,
case {Case,Result} of
{init_per_suite,_} ->
ok;
@@ -1201,8 +1213,8 @@ report(What,Data) ->
add_to_stats(auto_skipped);
{_,{skipped,_}} ->
add_to_stats(user_skipped);
- {_,{FailOrSkip,_Reason}} ->
- add_to_stats(FailOrSkip)
+ {_,{SkipOrFail,_Reason}} ->
+ add_to_stats(SkipOrFail)
end;
tc_user_skip ->
%% test case specified as skipped in testspec
@@ -1210,6 +1222,7 @@ report(What,Data) ->
ct_event:sync_notify(#event{name=tc_user_skip,
node=node(),
data=Data}),
+ ct_suite_callback:on_tc_skip(What, Data),
add_to_stats(user_skipped);
tc_auto_skip ->
%% test case skipped because of error in init_per_suite
@@ -1222,6 +1235,7 @@ report(What,Data) ->
ct_event:sync_notify(#event{name=tc_auto_skip,
node=node(),
data=Data}),
+ ct_suite_callback:on_tc_skip(What, Data),
if Case /= end_per_suite, Case /= end_per_group ->
add_to_stats(auto_skipped);
true ->
diff --git a/lib/common_test/src/ct_suite_callback.erl b/lib/common_test/src/ct_suite_callback.erl
index 00fbb425a1..dd4fc76c8b 100644
--- a/lib/common_test/src/ct_suite_callback.erl
+++ b/lib/common_test/src/ct_suite_callback.erl
@@ -28,6 +28,8 @@
-export([init_tc/3]).
-export([end_tc/5]).
-export([terminate/1]).
+-export([on_tc_skip/2]).
+-export([on_tc_fail/2]).
-type proplist() :: [{atom(),term()}].
@@ -109,6 +111,12 @@ end_tc(_Mod, {end_per_group, GroupName, _}, _Config, Result, _Return) ->
end_tc(_Mod, TC, _Config, Result, _Return) ->
call(fun call_generic/3, Result, {post_end_per_testcase, TC}).
+on_tc_skip(How, {_Suite, Case, Reason}) ->
+ 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}).
+
%% -------------------------------------------------------------------------
%% Internal Functions
%% -------------------------------------------------------------------------
@@ -122,6 +130,11 @@ 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],
+ {Reason,State}),
+ {Reason, {Mod, NewState}}.
+
call_generic({Mod, State}, Config, {Function, undefined}) ->
{NewConf, NewState} = catch_apply(Mod,Function,[Config, State],
{Config, State}),