aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/src/ct_suite_callback.erl
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2010-11-18 17:28:24 +0100
committerLukas Larsson <[email protected]>2010-12-08 18:07:49 +0100
commitf736305327fea94f0e014422f18ca8dcceb62389 (patch)
tree3ffd599252f99c682b5bb99c21ec4318af4d8713 /lib/common_test/src/ct_suite_callback.erl
parent92ad0e04b09ebe755e60fa0828c5799b3ce1f559 (diff)
downloadotp-f736305327fea94f0e014422f18ca8dcceb62389.tar.gz
otp-f736305327fea94f0e014422f18ca8dcceb62389.tar.bz2
otp-f736305327fea94f0e014422f18ca8dcceb62389.zip
Extend SCB error handling printouts
Update error behaviour so that a failing SCB callback results in a failing testcase
Diffstat (limited to 'lib/common_test/src/ct_suite_callback.erl')
-rw-r--r--lib/common_test/src/ct_suite_callback.erl22
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/common_test/src/ct_suite_callback.erl b/lib/common_test/src/ct_suite_callback.erl
index 503d7a6c9c..5b132306a3 100644
--- a/lib/common_test/src/ct_suite_callback.erl
+++ b/lib/common_test/src/ct_suite_callback.erl
@@ -50,7 +50,6 @@ init(Opts) ->
-spec terminate(Callbacks :: term()) ->
ok.
terminate(Callbacks) ->
- io:format("Callbacks: ~p",[Callbacks]),
call([{CBId, fun call_terminate/3} || {CBId,_} <- Callbacks],
ct_suite_callback_init_dummy, undefined, Callbacks),
ok.
@@ -109,7 +108,7 @@ call_init({Mod, State}, Config, _) ->
{Config, {Id, {Mod, NewState}}}.
call_terminate({Mod, State}, _, _) ->
- Mod:terminate(State),
+ catch_apply(Mod,terminate,[State], ok),
{[],{Mod,State}}.
call_generic({Mod, State}, Config, {Function, undefined}) ->
@@ -152,10 +151,8 @@ call([{CBId, Fun} | Rest], Config, Meta, CBs) ->
NewCalls = get_new_callbacks(NewConf, Fun),
call(NewCalls ++ Rest, remove(?config_name, NewConf), Meta,
lists:keyreplace(CBId, 1, CBs, {CBId, NewCBInfo}))
- catch Error:Reason ->
- ct_logs:log("Suite Callback","Call to SCB failed: ~p:~p",
- [Error,{Reason,erlang:get_stacktrace()}]),
- call(Rest, Config, Meta, CBs)
+ catch throw:{error_in_scb_call,Reason} ->
+ call(Rest, {fail, Reason}, Meta, CBs)
end;
call([], Config, _Meta, CBs) ->
ct_util:save_suite_data_async(?config_name, CBs),
@@ -188,11 +185,16 @@ get_callbacks() ->
catch_apply(M,F,A, Default) ->
try
apply(M,F,A)
- catch error:undef ->
+ catch error:Reason ->
case erlang:get_stacktrace() of
- [{M,F,A}|_] ->
+ [{M,F,A}|_] when Reason == undef ->
Default;
- _Else ->
- error(undef,[M,F,A])
+ Trace ->
+ ct_logs:log("Suite Callback","Call to SCB failed: ~p:~p",
+ [error,{Reason,Trace}]),
+ throw({error_in_scb_call,
+ lists:flatten(
+ io_lib:format("~p:~p/~p SCB call failed",
+ [M,F,length(A)]))})
end
end.