aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/src/ct.erl
diff options
context:
space:
mode:
authorPeter Andersson <[email protected]>2012-03-06 11:46:00 +0100
committerPeter Andersson <[email protected]>2012-03-06 11:46:00 +0100
commit319d7259672037e6999d7cdd0b469fbb5cadcf22 (patch)
tree9554ed30f87d36c4b79d2b3d7f4802c5daf4f6e3 /lib/common_test/src/ct.erl
parent725032aabda06c77934b461374b8657963f4ff1c (diff)
downloadotp-319d7259672037e6999d7cdd0b469fbb5cadcf22.tar.gz
otp-319d7259672037e6999d7cdd0b469fbb5cadcf22.tar.bz2
otp-319d7259672037e6999d7cdd0b469fbb5cadcf22.zip
Correct wrong location printout for ct:fail/1/2
OTP-9933
Diffstat (limited to 'lib/common_test/src/ct.erl')
-rw-r--r--lib/common_test/src/ct.erl24
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/common_test/src/ct.erl b/lib/common_test/src/ct.erl
index e0e82283c4..00701f5a2d 100644
--- a/lib/common_test/src/ct.erl
+++ b/lib/common_test/src/ct.erl
@@ -585,8 +585,16 @@ capture_get([]) ->
%%% @doc Terminate a test case with the given error
%%% <code>Reason</code>.
fail(Reason) ->
- exit({test_case_failed,Reason}).
-
+ try
+ exit({test_case_failed,Reason})
+ catch
+ Class:R ->
+ case erlang:get_stacktrace() of
+ [{?MODULE,fail,1,_}|Stk] -> ok;
+ Stk -> ok
+ end,
+ erlang:raise(Class, R, Stk)
+ end.
%%%-----------------------------------------------------------------
%%% @spec fail(Format, Args) -> void()
@@ -599,13 +607,21 @@ fail(Reason) ->
fail(Format, Args) ->
try io_lib:format(Format, Args) of
Str ->
- exit({test_case_failed,lists:flatten(Str)})
+ try
+ exit({test_case_failed,lists:flatten(Str)})
+ catch
+ Class:R ->
+ case erlang:get_stacktrace() of
+ [{?MODULE,fail,2,_}|Stk] -> ok;
+ Stk -> ok
+ end,
+ erlang:raise(Class, R, Stk)
+ end
catch
_:BadArgs ->
exit({BadArgs,{?MODULE,fail,[Format,Args]}})
end.
-
%%%-----------------------------------------------------------------
%%% @spec comment(Comment) -> void()
%%% Comment = term()