From db87ef023f4660fd2129f30dbbff05e73bff3dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Fri, 26 Feb 2016 06:47:38 +0100 Subject: Modernize use of timetraps Either rely on the default 30 minutes timetrap, or set the timeout using the supported methods in common_test. --- lib/stdlib/test/re_SUITE.erl | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) (limited to 'lib/stdlib/test/re_SUITE.erl') diff --git a/lib/stdlib/test/re_SUITE.erl b/lib/stdlib/test/re_SUITE.erl index bd495ce587..d1720bd4bc 100644 --- a/lib/stdlib/test/re_SUITE.erl +++ b/lib/stdlib/test/re_SUITE.erl @@ -33,7 +33,9 @@ -include_lib("common_test/include/ct.hrl"). -include_lib("kernel/include/file.hrl"). -suite() -> [{ct_hooks,[ts_install_cth]}]. +suite() -> + [{ct_hooks,[ts_install_cth]}, + {timetrap,{minutes,3}}]. all() -> [pcre, compile_options, run_options, combined_options, @@ -64,11 +66,9 @@ end_per_group(_GroupName, Config) -> pcre(doc) -> ["Run all applicable tests from the PCRE testsuites."]; pcre(Config) when is_list(Config) -> - Dog = ?t:timetrap(?t:minutes(3)), RootDir = ?config(data_dir, Config), Res = run_pcre_tests:test(RootDir), 0 = lists:sum([ X || {X,_,_} <- Res ]), - ?t:timetrap_cancel(Dog), {comment,Res}. compile_options(doc) -> @@ -270,15 +270,12 @@ combined_options(Config) when is_list(Config) -> replace_autogen(doc) -> ["Test replace with autogenerated erlang module"]; replace_autogen(Config) when is_list(Config) -> - Dog = ?t:timetrap(?t:minutes(3)), re_testoutput1_replacement_test:run(), - ?t:timetrap_cancel(Dog), ok. global_capture(doc) -> ["Tests capture options together with global searching"]; global_capture(Config) when is_list(Config) -> - Dog = ?t:timetrap(?t:minutes(3)), ?line {match,[{3,4}]} = re:run("ABCabcdABC",".*(?abcd).*",[{capture,[1]}]), ?line {match,[{10,4}]} = re:run("ABCabcdABCabcdA",".*(?abcd).*",[{capture,[1]}]), ?line {match,[[{10,4}]]} = re:run("ABCabcdABCabcdA",".*(?abcd).*",[global,{capture,[1]}]), @@ -302,23 +299,19 @@ global_capture(Config) when is_list(Config) -> ?line {match,[["Åbcd","bcd"],["abcd","bcd"]]} = re:run(<<"ABC",8#303,8#205,"bcdABCabcdA">>,".(?bcd)",[global,{capture,all,list},unicode]), ?line {match,[["Åbcd","bcd"],["abcd","bcd"]]} = re:run("ABCÅbcdABCabcdA",".(?bcd)",[global,{capture,all,list},unicode]), ?line {match,[[{3,5},{5,3}],[{11,4},{12,3}]]} = re:run("ABCÅbcdABCabcdA",".(?bcd)",[global,{capture,all,index},unicode]), - ?t:timetrap_cancel(Dog), ok. replace_input_types(doc) -> ["Tests replace with different input types"]; replace_input_types(Config) when is_list(Config) -> - Dog = ?t:timetrap(?t:minutes(3)), ?line <<"abcd">> = re:replace("abcd","Z","X",[{return,binary},unicode]), ?line <<"abcd">> = re:replace("abcd","\x{400}","X",[{return,binary},unicode]), ?line <<"a",208,128,"cd">> = re:replace(<<"abcd">>,"b","\x{400}",[{return,binary},unicode]), - ?t:timetrap_cancel(Dog), ok. replace_return(doc) -> ["Tests return options of replace together with global searching"]; replace_return(Config) when is_list(Config) -> - Dog = ?t:timetrap(?t:minutes(3)), {'EXIT',{badarg,_}} = (catch re:replace("na","(a","")), ok = replacetest(<<"nisse">>,"i","a",[{return,binary}],<<"nasse">>), ok = replacetest("ABC\305abcdABCabcdA","a(?bcd)","X",[global,{return,binary}],<<"ABCÅXABCXA">>), @@ -339,7 +332,6 @@ replace_return(Config) when is_list(Config) -> ok = replacetest("a\x{400}bcd","d","X",[global,{return,binary},unicode],<<"a",208,128,"bcX">>), ok = replacetest("a\x{400}bcd","Z","X",[global,{return,list},unicode],"a\x{400}bcd"), ok = replacetest("a\x{400}bcd","Z","X",[global,{return,binary},unicode],<<"a",208,128,"bcd">>), - ?t:timetrap_cancel(Dog), ok. rtest(Subj, RE, Copt, Ropt, true) -> @@ -415,15 +407,12 @@ copt(_) -> false. split_autogen(doc) -> ["Test split with autogenerated erlang module"]; split_autogen(Config) when is_list(Config) -> - Dog = ?t:timetrap(?t:minutes(3)), re_testoutput1_split_test:run(), - ?t:timetrap_cancel(Dog), ok. split_options(doc) -> ["Test special options to split."]; split_options(Config) when is_list(Config) -> - Dog = ?t:timetrap(?t:minutes(1)), ok = splittest("a b c ","( )",[group,trim],[[<<"a">>,<<" ">>],[<<"b">>,<<" ">>],[<<"c">>,<<" ">>]]), ok = splittest("a b c ","( )",[group,{parts,0}],[[<<"a">>,<<" ">>],[<<"b">>,<<" ">>],[<<"c">>,<<" ">>]]), ok = splittest("a b c ","( )",[{parts,infinity},group],[[<<"a">>,<<" ">>],[<<"b">>,<<" ">>],[<<"c">>,<<" ">>],[<<>>]]), @@ -441,7 +430,6 @@ split_options(Config) when is_list(Config) -> {'EXIT',{badarg,_}} = (catch re:split("a b c d","( +)",[{capture,[],binary}])), % Parts 0 is equal to no parts specification (implicit strip) ok = splittest("a b c d","( *)",[{parts,0},{return,list}],["a"," ","b"," ","c"," ","d"]), - ?t:timetrap_cancel(Dog), ok. join([]) -> []; @@ -452,12 +440,10 @@ split_specials(doc) -> ["Some special cases of split that are easy to get wrong."]; split_specials(Config) when is_list(Config) -> %% More or less just to remember these icky cases - Dog = ?t:timetrap(?t:minutes(1)), ?line <<"::abd:f">> = iolist_to_binary(join(re:split("abdf","^(?!(ab)de|x)(abd)(f)",[trim]))), ?line <<":abc2xyzabc3">> = iolist_to_binary(join(re:split("abc1abc2xyzabc3","\\Aabc.",[trim]))), - ?t:timetrap_cancel(Dog), ok. @@ -474,7 +460,7 @@ error_handling(_Config) -> error_handling() -> % This test checks the exception tuples manufactured in the erlang % code to hide the trapping from the user at least when it comes to errors - Dog = ?t:timetrap(?t:minutes(1)), + % The malformed precomiled RE is detected after % the trap to re:grun from grun, in the grun function clause % that handles precompiled expressions @@ -625,7 +611,6 @@ error_handling() -> [banana]],_}, {?MODULE,error_handling,0,_} | _]}} = (catch re:split("apa","(p",[banana])), - ?t:timetrap_cancel(Dog), ok. pcre_cve_2008_2371(doc) -> @@ -645,7 +630,6 @@ pcre_compile_workspace_overflow(Config) when is_list(Config) -> re_infinite_loop(doc) -> "Make sure matches that really loop infinitely actually fail"; re_infinite_loop(Config) when is_list(Config) -> - Dog = ?t:timetrap(?t:minutes(1)), Str = "http:/www.flickr.com/slideShow/index.gne?group_id=&user_id=69845378@N0", EMail_regex = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+" @@ -657,17 +641,14 @@ re_infinite_loop(Config) when is_list(Config) -> nomatch = re:run(Str, EMail_regex, [global]), {error,match_limit} = re:run(Str, EMail_regex,[report_errors]), {error,match_limit} = re:run(Str, EMail_regex,[report_errors,global]), - ?t:timetrap_cancel(Dog), ok. re_backwards_accented(doc) -> "Check for nasty bug where accented graphemes can make PCRE back past " "beginning of subject"; re_backwards_accented(Config) when is_list(Config) -> - Dog = ?t:timetrap(?t:minutes(1)), ?line match = re:run(<<65,204,128,65,204,128,97,98,99>>, <<"\\X?abc">>, [unicode,{capture,none}]), - ?t:timetrap_cancel(Dog), ok. opt_dupnames(doc) -> "Check correct handling of dupnames option to re"; -- cgit v1.2.3