aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/src/ct_suite_callback.erl
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2010-11-23 17:42:11 +0100
committerLukas Larsson <[email protected]>2010-12-08 18:07:52 +0100
commit2f95eaaee45add848df49c84bd449f5c52d63000 (patch)
treef6a6fb521877dc166452bc670da86b80b6b71a14 /lib/common_test/src/ct_suite_callback.erl
parent53196e4720f316800eedaec2ce4792683cb3c80e (diff)
downloadotp-2f95eaaee45add848df49c84bd449f5c52d63000.tar.gz
otp-2f95eaaee45add848df49c84bd449f5c52d63000.tar.bz2
otp-2f95eaaee45add848df49c84bd449f5c52d63000.zip
Add on_tc_fail and on_tc_skip functionality
Diffstat (limited to 'lib/common_test/src/ct_suite_callback.erl')
-rw-r--r--lib/common_test/src/ct_suite_callback.erl13
1 files changed, 13 insertions, 0 deletions
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}),