From 2f95eaaee45add848df49c84bd449f5c52d63000 Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Tue, 23 Nov 2010 17:42:11 +0100 Subject: Add on_tc_fail and on_tc_skip functionality --- lib/common_test/src/ct_suite_callback.erl | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lib/common_test/src/ct_suite_callback.erl') 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}), -- cgit v1.2.3