diff options
author | Dan Gudmundsson <[email protected]> | 2014-03-12 15:15:45 +0100 |
---|---|---|
committer | Dan Gudmundsson <[email protected]> | 2014-03-12 15:15:45 +0100 |
commit | 32f8a87f9b60668d09be276e8b6fdf2f34cfa880 (patch) | |
tree | 29c3fa8f8a1b5aae933323e48661899010452ccd /lib/test_server/src/test_server.erl | |
parent | 965d5185d61ce33a8a136b1df42e764e7c95896d (diff) | |
download | otp-32f8a87f9b60668d09be276e8b6fdf2f34cfa880.tar.gz otp-32f8a87f9b60668d09be276e8b6fdf2f34cfa880.tar.bz2 otp-32f8a87f9b60668d09be276e8b6fdf2f34cfa880.zip |
test_server: Allow init_per_ function to throw skip
Allow all init_per_[suite|group|testcase] to throw (or exit)
{skip, Reason} to explicitly ignore tests without failing.
It is easier to catch it in one place instead of writing a try
in each init_per_* to return {skip, Reason}.
Diffstat (limited to 'lib/test_server/src/test_server.erl')
-rw-r--r-- | lib/test_server/src/test_server.erl | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/test_server/src/test_server.erl b/lib/test_server/src/test_server.erl index 82672521f7..9b05bddf63 100644 --- a/lib/test_server/src/test_server.erl +++ b/lib/test_server/src/test_server.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1996-2013. All Rights Reserved. +%% Copyright Ericsson AB 1996-2014. All Rights Reserved. %% %% The contents of this file are subject to the Erlang Public License, %% Version 1.1, (the "License"); you may not use this file except in @@ -1208,6 +1208,10 @@ do_init_per_testcase(Mod, Args) -> "a Config list.\n",[]}, {skip,{failed,{Mod,init_per_testcase,bad_return}}} catch + throw:{Skip,Reason} when Skip =:= skip; Skip =:= skipped -> + {skip,Reason}; + exit:{Skip,Reason} when Skip =:= skip; Skip =:= skipped -> + {skip,Reason}; throw:Other -> set_loc(erlang:get_stacktrace()), Line = get_loc(), @@ -1378,6 +1382,10 @@ ts_tc(M, F, A) -> Result = try apply(M, F, A) catch + throw:{skip, Reason} -> {skip, Reason}; + throw:{skipped, Reason} -> {skip, Reason}; + exit:{skip, Reason} -> {skip, Reason}; + exit:{skipped, Reason} -> {skip, Reason}; Type:Reason -> Stk = erlang:get_stacktrace(), set_loc(Stk), |