diff options
author | Peter Andersson <[email protected]> | 2011-11-30 16:56:05 +0100 |
---|---|---|
committer | Peter Andersson <[email protected]> | 2011-11-30 16:56:05 +0100 |
commit | 4f72bfff6cbcb69ae0b54f1958fab575d4d366f9 (patch) | |
tree | 8487d141a1fce48ab4b858af61725f3386a2ac19 /lib/common_test | |
parent | 08ea3af8528ad0920021ecc230a66eb5ee59bc86 (diff) | |
download | otp-4f72bfff6cbcb69ae0b54f1958fab575d4d366f9.tar.gz otp-4f72bfff6cbcb69ae0b54f1958fab575d4d366f9.tar.bz2 otp-4f72bfff6cbcb69ae0b54f1958fab575d4d366f9.zip |
Add ct:fail/2 function
Diffstat (limited to 'lib/common_test')
-rw-r--r-- | lib/common_test/src/ct.erl | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/common_test/src/ct.erl b/lib/common_test/src/ct.erl index 69e15fa246..9e787ef508 100644 --- a/lib/common_test/src/ct.erl +++ b/lib/common_test/src/ct.erl @@ -63,7 +63,7 @@ log/1, log/2, log/3, print/1, print/2, print/3, pal/1, pal/2, pal/3, - fail/1, comment/1, + fail/1, fail/2, comment/1, testcases/2, userdata/2, userdata/3, timetrap/1, sleep/1]). @@ -528,6 +528,25 @@ pal(Category,Format,Args) -> fail(Reason) -> exit({test_case_failed,Reason}). + +%%%----------------------------------------------------------------- +%%% @spec fail(Format, Args) -> void() +%%% Format = string() +%%% Args = list() +%%% +%%% @doc Terminate a test case with an error message specified +%%% by a format string and a list of values (used as arguments to +%%% <code>io_lib:format/2</code>). +fail(Format, Args) -> + try io_lib:format(Format, Args) of + Str -> + exit({test_case_failed,lists:flatten(Str)}) + catch + _:BadArgs -> + exit({BadArgs,{?MODULE,fail,[Format,Args]}}) + end. + + %%%----------------------------------------------------------------- %%% @spec comment(Comment) -> void() %%% Comment = term() |