aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2011-08-26 14:43:27 +0200
committerBjörn Gustavsson <[email protected]>2011-09-13 09:48:26 +0200
commit4c747daecf8bfd22dafaf0e0d649ad02ec813f13 (patch)
tree6f3077992622ab63967cfbfbf049f7c0a5c58a3c /lib
parent9596e88e69880d2aa769bee5a7d346f2bf365e92 (diff)
downloadotp-4c747daecf8bfd22dafaf0e0d649ad02ec813f13.tar.gz
otp-4c747daecf8bfd22dafaf0e0d649ad02ec813f13.tar.bz2
otp-4c747daecf8bfd22dafaf0e0d649ad02ec813f13.zip
test_server: Show line number for caller of test_server:fail()
Showing the line number of fail/{1,2} in the test_server module is not especially useful.
Diffstat (limited to 'lib')
-rw-r--r--lib/test_server/src/test_server.erl22
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/test_server/src/test_server.erl b/lib/test_server/src/test_server.erl
index 04f92c5738..2cb33a9a69 100644
--- a/lib/test_server/src/test_server.erl
+++ b/lib/test_server/src/test_server.erl
@@ -1716,7 +1716,16 @@ adjusted_sleep(MSecs) ->
%% to read when using this function, rather than exit directly.
fail(Reason) ->
comment(cast_to_list(Reason)),
- exit({suite_failed,Reason}).
+ try
+ exit({suite_failed,Reason})
+ catch
+ Class:R ->
+ case erlang:get_stacktrace() of
+ [{?MODULE,fail,1,_}|Stk] -> ok;
+ Stk -> ok
+ end,
+ erlang:raise(Class, R, Stk)
+ end.
cast_to_list(X) when is_list(X) -> X;
cast_to_list(X) when is_atom(X) -> atom_to_list(X);
@@ -1730,7 +1739,16 @@ cast_to_list(X) -> lists:flatten(io_lib:format("~p", [X])).
%% Immediately calls exit. Included because test suites are easier
%% to read when using this function, rather than exit directly.
fail() ->
- exit(suite_failed).
+ try
+ exit(suite_failed)
+ catch
+ Class:R ->
+ case erlang:get_stacktrace() of
+ [{?MODULE,fail,0,_}|Stk] -> ok;
+ Stk -> ok
+ end,
+ erlang:raise(Class, R, Stk)
+ end.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% break(Comment) -> ok