From 117daae14c7779a35659589a842af331fe773d6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Thu, 25 Feb 2016 15:28:25 +0100 Subject: Eliminate use of test_server:fail/0,1 --- lib/compiler/test/beam_validator_SUITE.erl | 2 +- lib/compiler/test/bs_construct_SUITE.erl | 6 +++--- lib/compiler/test/bs_match_SUITE.erl | 6 +++--- lib/compiler/test/compilation_SUITE.erl | 12 ++++++------ lib/compiler/test/compile_SUITE.erl | 6 +++--- lib/compiler/test/error_SUITE.erl | 3 +-- lib/compiler/test/float_SUITE.erl | 2 +- lib/compiler/test/fun_SUITE.erl | 4 ++-- lib/compiler/test/guard_SUITE.erl | 6 +++--- lib/compiler/test/inline_SUITE.erl | 4 ++-- lib/compiler/test/lc_SUITE.erl | 2 +- lib/compiler/test/map_SUITE.erl | 6 +++--- lib/compiler/test/misc_SUITE.erl | 4 ++-- lib/compiler/test/receive_SUITE.erl | 6 +++--- lib/compiler/test/record_SUITE.erl | 6 +++--- lib/compiler/test/regressions_SUITE.erl | 3 +-- lib/compiler/test/test_lib.erl | 3 ++- lib/compiler/test/warnings_SUITE.erl | 5 ++--- 18 files changed, 42 insertions(+), 44 deletions(-) diff --git a/lib/compiler/test/beam_validator_SUITE.erl b/lib/compiler/test/beam_validator_SUITE.erl index 2024b6ab77..9b8bd3206b 100644 --- a/lib/compiler/test/beam_validator_SUITE.erl +++ b/lib/compiler/test/beam_validator_SUITE.erl @@ -93,7 +93,7 @@ compiler_bug(Config) when is_list(Config) -> stupid_but_valid(Config) when is_list(Config) -> AnAtom = nisse, ?line try setelement(5, setelement(6, AnAtom, value), another_value) of - Term -> ?line ?t:fail({what_happened,Term}) + Term -> ct:fail({what_happened,Term}) catch error:badarg -> ok end, diff --git a/lib/compiler/test/bs_construct_SUITE.erl b/lib/compiler/test/bs_construct_SUITE.erl index 811cb42bd9..e24b3f0315 100644 --- a/lib/compiler/test/bs_construct_SUITE.erl +++ b/lib/compiler/test/bs_construct_SUITE.erl @@ -199,7 +199,7 @@ one_test({C_bin, E_bin, Str, Bytes}) when is_list(Bytes) -> true -> io:format("ERROR: Compiled: ~p. Expected ~p. Got ~p.~n", [Str, Bytes, bitstring_to_list(C_bin)]), - test_server:fail(comp) + ct:fail(comp) end, if E_bin == Bin -> @@ -207,7 +207,7 @@ one_test({C_bin, E_bin, Str, Bytes}) when is_list(Bytes) -> true -> io:format("ERROR: Interpreted: ~p. Expected ~p. Got ~p.~n", [Str, Bytes, bitstring_to_list(E_bin)]), - test_server:fail(comp) + ct:fail(comp) end; one_test({C_bin, E_bin, Str, Result}) -> io:format(" ~s ~p~n", [Str, C_bin]), @@ -228,7 +228,7 @@ one_test({C_bin, E_bin, Str, Result}) -> io:format("ERROR: Compiled not equal to interpreted:" "~n ~p, ~p.~n", [bitstring_to_list(C_bin), bitstring_to_list(E_bin)]), - test_server:fail(comp); + ct:fail(comp); 0 -> ok; %% For situations where the final bits may not matter, like diff --git a/lib/compiler/test/bs_match_SUITE.erl b/lib/compiler/test/bs_match_SUITE.erl index 01e0cbb5f3..2b821ac141 100644 --- a/lib/compiler/test/bs_match_SUITE.erl +++ b/lib/compiler/test/bs_match_SUITE.erl @@ -123,7 +123,7 @@ int_float(Config) when is_list(Config) -> %% Coverage of error cases in sys_pre_expand:coerce_to_float/2. case id(default) of <<(1 bsl 1024):64/float>> -> - ?t:fail(); + ct:fail(should_not_match); default -> ok end. @@ -305,7 +305,7 @@ save_restore(Config) when is_list(Config) -> Bin = <<-1:64>>, case bad_float_unpack_match(Bin) of -1 -> ok; - _Other -> ?line ?t:fail(bad_return_value_probably_NaN) + _Other -> ct:fail(bad_return_value_probably_NaN) end. save_restore_1(Bin) -> @@ -1033,7 +1033,7 @@ zero_width(Config) when is_list(Config) -> %% Match sure that values that cannot fit in a segment will not match. case id(<<0:8>>) of - <<256:8>> -> ?line ?t:fail(); + <<256:8>> -> ct:fail(should_not_match); _ -> ok end, ok. diff --git a/lib/compiler/test/compilation_SUITE.erl b/lib/compiler/test/compilation_SUITE.erl index 8745e0d129..d1c2113ba4 100644 --- a/lib/compiler/test/compilation_SUITE.erl +++ b/lib/compiler/test/compilation_SUITE.erl @@ -205,7 +205,7 @@ failure(Module, Conf) -> ?line case CompRc of error -> ok; {error,Errors,_} -> check_errors(Errors); - _ -> test_server:fail({no_error, CompRc}) + _ -> ct:fail({no_error, CompRc}) end, ok. @@ -227,7 +227,7 @@ check_error_1(Str0) -> io:format("~s\n", [Str]), case Str of "internal"++_=Str -> - ?t:fail(internal_compiler_error); + ct:fail(internal_compiler_error); _ -> ok end. @@ -331,7 +331,7 @@ start_node(Name, Args) -> {ok, Node} -> {ok, Node}; Error -> - ?line test_server:fail(Error) + ct:fail(Error) end. from(H, [H | T]) -> T; @@ -360,7 +360,7 @@ vsn_1(Conf) when is_list(Conf) -> Vsn1 == Vsn2, Vsn2 == Vsn3 -> ok; true -> - test_server:fail({vsn, Vsn1, Vsn2, Vsn3}) + ct:fail({vsn, Vsn1, Vsn2, Vsn3}) end, ok. @@ -376,7 +376,7 @@ vsn_2(Conf) when is_list(Conf) -> [34] -> ok; _ -> - test_server:fail({vsn, Vsn}) + ct:fail({vsn, Vsn}) end, ok. @@ -397,7 +397,7 @@ vsn_3(Conf) when is_list(Conf) -> Vsn1 /= Vsn2 -> ok; true -> - test_server:fail({vsn, Vsn1, Vsn2}) + ct:fail({vsn, Vsn1, Vsn2}) end, ok. diff --git a/lib/compiler/test/compile_SUITE.erl b/lib/compiler/test/compile_SUITE.erl index 548abacc08..f3217b8c39 100644 --- a/lib/compiler/test/compile_SUITE.erl +++ b/lib/compiler/test/compile_SUITE.erl @@ -115,7 +115,7 @@ file_1(Config) when is_list(Config) -> %% There should not be any messages in the messages. receive Any -> - ?t:fail({unexpected,Any}) + ct:fail({unexpected,Any}) after 10 -> ok end, @@ -543,7 +543,7 @@ do_listing(Source, TargetDir, Type, Ext) -> [Source, TargetDir, Type, Ext]), case compile:file(Source, [Type, time, {outdir, TargetDir}]) of {ok, _} -> ok; - Other -> test_server:fail({unexpected_result, Other}) + Other -> ct:fail({unexpected_result, Other}) end, SourceBase = filename:rootname(filename:basename(Source)), @@ -654,7 +654,7 @@ test(Iter, Fun, Result, Filler) -> test(Iter-1, Fun, Result, [0|Filler]); {result, Other} -> io:format("Expected ~p; got ~p~n", [Result, Other]), - test_server:fail() + ct:fail(failed) end. init(ReplyTo, Fun, _Filler) -> diff --git a/lib/compiler/test/error_SUITE.erl b/lib/compiler/test/error_SUITE.erl index 86377b9f34..64ab9eb10a 100644 --- a/lib/compiler/test/error_SUITE.erl +++ b/lib/compiler/test/error_SUITE.erl @@ -389,5 +389,4 @@ run_test(Test0, File, Warnings, WriteBeam) -> Res. fail() -> - io:format("failed~n"), - ?t:fail(). + ct:fail(failed). diff --git a/lib/compiler/test/float_SUITE.erl b/lib/compiler/test/float_SUITE.erl index 60efe4f228..ec64ef6901 100644 --- a/lib/compiler/test/float_SUITE.erl +++ b/lib/compiler/test/float_SUITE.erl @@ -53,7 +53,7 @@ end_per_group(_GroupName, Config) -> pending(Config) when is_list(Config) -> ?line case catch float_mul(1, 1.1e300, 3.14e300) of {'EXIT',{badarith,_}} -> ok; - Other -> ?t:fail({expected_exception,Other}) + Other -> ct:fail({expected_exception,Other}) end, ?line 0.0 = float_sub(2.0). diff --git a/lib/compiler/test/fun_SUITE.erl b/lib/compiler/test/fun_SUITE.erl index c6cc5b17b3..9b6e14217d 100644 --- a/lib/compiler/test/fun_SUITE.erl +++ b/lib/compiler/test/fun_SUITE.erl @@ -93,7 +93,7 @@ one_test({C, E, Str, Correct}) -> true -> io:format("ERROR: Compiled: ~p. Expected ~p. Got ~p.~n", [Str, Correct, C]), - test_server:fail(comp) + ct:fail(comp) end, if E == Correct -> @@ -101,7 +101,7 @@ one_test({C, E, Str, Correct}) -> true -> io:format("ERROR: Interpreted: ~p. Expected ~p. Got ~p.~n", [Str, Correct, E]), - test_server:fail(comp) + ct:fail(comp) end. -record(b, {c}). diff --git a/lib/compiler/test/guard_SUITE.erl b/lib/compiler/test/guard_SUITE.erl index 8d1baef63d..eb3feb6307 100644 --- a/lib/compiler/test/guard_SUITE.erl +++ b/lib/compiler/test/guard_SUITE.erl @@ -1778,11 +1778,11 @@ bptest(_,_,_) -> -define(FAILING(C), if - C -> ?t:fail(should_fail); + C -> ct:fail(should_fail); true -> ok end, if - true, C -> ?t:fail(should_fail); + true, C -> ct:fail(should_fail); true -> ok end). @@ -1915,7 +1915,7 @@ check(F, Result) -> Other -> io:format("Expected: ~p\n", [Result]), io:format(" Got: ~p\n", [Other]), - test_server:fail() + ct:fail(check_failed) end. fc({'EXIT',{function_clause,_}}) -> ok; diff --git a/lib/compiler/test/inline_SUITE.erl b/lib/compiler/test/inline_SUITE.erl index efe5ad3162..cb552e16e3 100644 --- a/lib/compiler/test/inline_SUITE.erl +++ b/lib/compiler/test/inline_SUITE.erl @@ -140,13 +140,13 @@ compare([{X,Y,RGB1}|T1], [{X,Y,RGB2}|T2]) -> compare(T1, T2); compare([H1|_], [H2|_]) -> io:format("Normal = ~p, Inlined = ~p\n", [H1,H2]), - ?t:fail(); + ct:fail(different); compare([], []) -> ok. start_node(Name, Args) -> case test_server:start_node(Name, slave, [{args,Args}]) of {ok,Node} -> {ok, Node}; - Error -> ?line test_server:fail(Error) + Error -> ct:fail(Error) end. load_and_call(Out, Module) -> diff --git a/lib/compiler/test/lc_SUITE.erl b/lib/compiler/test/lc_SUITE.erl index 1de4fe95c6..70c80d3353 100644 --- a/lib/compiler/test/lc_SUITE.erl +++ b/lib/compiler/test/lc_SUITE.erl @@ -170,7 +170,7 @@ no_gen_verify(Res, A, B) -> ShouldBe -> ok; _ -> io:format("A = ~p; B = ~p; Expected = ~p, actual = ~p", [A,B,ShouldBe,Res]), - ?t:fail() + ct:fail(failed) end. no_gen_eval(Fun, Res) -> diff --git a/lib/compiler/test/map_SUITE.erl b/lib/compiler/test/map_SUITE.erl index af98584e00..14d175b92c 100644 --- a/lib/compiler/test/map_SUITE.erl +++ b/lib/compiler/test/map_SUITE.erl @@ -1479,7 +1479,7 @@ t_guard_fun(Config) when is_list(Config) -> {'EXIT', {function_clause,[{?MODULE,_,[#{s:=none,v:=none}],_}|_]}} -> ok; {'EXIT', {{case_clause,_},_}} -> {comment,inlined}; Other -> - test_server:fail({no_match, Other}) + ct:fail({no_match, Other}) end. @@ -1565,7 +1565,7 @@ t_build_and_match_empty_val(Config) when is_list(Config) -> {'EXIT',{function_clause,_}} -> ok; {'EXIT', {{case_clause,_},_}} -> {comment,inlined}; Other -> - test_server:fail({no_match, Other}) + ct:fail({no_match, Other}) end. t_build_and_match_val(Config) when is_list(Config) -> @@ -1583,7 +1583,7 @@ t_build_and_match_val(Config) when is_list(Config) -> {'EXIT',{function_clause,_}} -> ok; {'EXIT', {{case_clause,_},_}} -> {comment,inlined}; Other -> - test_server:fail({no_match, Other}) + ct:fail({no_match, Other}) end. t_build_and_match_nil(Config) when is_list(Config) -> diff --git a/lib/compiler/test/misc_SUITE.erl b/lib/compiler/test/misc_SUITE.erl index ce6c21ed76..d60141a10a 100644 --- a/lib/compiler/test/misc_SUITE.erl +++ b/lib/compiler/test/misc_SUITE.erl @@ -310,14 +310,14 @@ expect_error(Fun) -> try Fun() of Any -> io:format("~p", [Any]), - ?t:fail(call_was_supposed_to_fail) + ct:fail(call_was_supposed_to_fail) catch Class:Reason -> Stk = erlang:get_stacktrace(), io:format("~p:~p\n~p\n", [Class,Reason,Stk]), case {Class,Reason} of {error,undef} -> - ?t:fail(not_supposed_to_fail_with_undef); + ct:fail(not_supposed_to_fail_with_undef); {_,_} -> ok end diff --git a/lib/compiler/test/receive_SUITE.erl b/lib/compiler/test/receive_SUITE.erl index a01672f46d..59a2e66b9e 100644 --- a/lib/compiler/test/receive_SUITE.erl +++ b/lib/compiler/test/receive_SUITE.erl @@ -70,14 +70,14 @@ recv(Config) when is_list(Config) -> {ok,test} -> ok; {error,Other} -> io:format("Got unpexected ~p", [Other]), - ?line ?t:fail() + ct:fail(unexpected) after 10000 -> - ?line ?t:fail(no_answer) + ct:fail(no_answer) end, receive X -> io:format("Unexpected extra message: ~p", [X]), - ?line ?t:fail() + ct:fail(unexpected) after 10 -> ok end, diff --git a/lib/compiler/test/record_SUITE.erl b/lib/compiler/test/record_SUITE.erl index cc2ea5d20a..96b6e26ee2 100644 --- a/lib/compiler/test/record_SUITE.erl +++ b/lib/compiler/test/record_SUITE.erl @@ -117,8 +117,8 @@ update_foo_barf(#foo{}=R, A, _B, C, D, E) -> R#barf{a=A,b=A,c=C,d=D,e=E}. --define(TrueGuard(Expr), if Expr -> ok; true -> ?t:fail() end). --define(FalseGuard(Expr), if Expr -> ?t:fail(); true -> ok end). +-define(TrueGuard(Expr), if Expr -> ok; true -> ct:fail(failed) end). +-define(FalseGuard(Expr), if Expr -> ct:fail(failed); true -> ok end). record_test_2(Config) when is_list(Config) -> ?line true = is_record(#foo{}, foo), @@ -514,7 +514,7 @@ once(Test, Record) -> 1 -> ok; N -> io:format("Evaluated ~w times\n", [N]), - ?t:fail() + ct:fail(more_than_once) end, Result. diff --git a/lib/compiler/test/regressions_SUITE.erl b/lib/compiler/test/regressions_SUITE.erl index 0e641fcd71..65fd213649 100644 --- a/lib/compiler/test/regressions_SUITE.erl +++ b/lib/compiler/test/regressions_SUITE.erl @@ -91,5 +91,4 @@ run_test(Conf, Test0) -> ok. fail() -> - io:format("failed~n"), - ?t:fail(). + ct:fail(failed). diff --git a/lib/compiler/test/test_lib.erl b/lib/compiler/test/test_lib.erl index 5768b67a56..beb03859c7 100644 --- a/lib/compiler/test/test_lib.erl +++ b/lib/compiler/test/test_lib.erl @@ -118,7 +118,8 @@ p_run_loop(_, [], _, [], Errors, Ws) -> 1 -> {comment,"1 warning"}; N -> {comment,integer_to_list(N)++" warnings"} end; - N -> ?t:fail({N,errors}) + N -> + ct:fail({N,errors}) end; p_run_loop(Test, [H|T], N, Refs, Errors, Ws) when length(Refs) < N -> {_,Ref} = erlang:spawn_monitor(fun() -> exit(Test(H)) end), diff --git a/lib/compiler/test/warnings_SUITE.erl b/lib/compiler/test/warnings_SUITE.erl index 1d62496044..af32ed79fa 100644 --- a/lib/compiler/test/warnings_SUITE.erl +++ b/lib/compiler/test/warnings_SUITE.erl @@ -340,7 +340,7 @@ bad_apply(Config) when is_list(Config) -> %% Also verify that the generated code generates the correct error. ?line try erlang:42() of - _ -> ?line ?t:fail() + _ -> ct:fail(should_fail) catch error:badarg -> ok end, @@ -830,5 +830,4 @@ run_test(Conf, Test0, Warnings) -> Res. fail() -> - io:format("failed~n"), - ?t:fail(). + ct:fail(failed). -- cgit v1.2.3