From 926dbcfbb4683f4c217504c590e36cb76f06dced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 31 Oct 2012 16:24:43 +0100 Subject: Make sure that "Testing..." is not written if testing has finished When writing messages to stdout, all messages are prefixed with "Testing" followed by the name of the test suite. We don't want to write that prefix if testing has stopped. --- lib/test_server/src/test_server_ctrl.erl | 1 + lib/test_server/src/test_server_io.erl | 2 ++ 2 files changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/test_server/src/test_server_ctrl.erl b/lib/test_server/src/test_server_ctrl.erl index 4e465c02d1..6ea69b5e58 100644 --- a/lib/test_server/src/test_server_ctrl.erl +++ b/lib/test_server/src/test_server_ctrl.erl @@ -1416,6 +1416,7 @@ init_tester(Mod, Func, Args, Dir, Name, {_,_,MinLev}=Levels, group_leader(test_server_io:get_gl(true), self()), {TimeMy,Result} = ts_tc(Mod, Func, Args), set_io_buffering(undefined), + test_server_io:set_job_name(undefined), catch stop_extra_tools(StartedExtraTools), case Result of {'EXIT',test_suites_done} -> diff --git a/lib/test_server/src/test_server_io.erl b/lib/test_server/src/test_server_io.erl index abdfb71241..7ec36d0c1f 100644 --- a/lib/test_server/src/test_server_io.erl +++ b/lib/test_server/src/test_server_io.erl @@ -253,6 +253,8 @@ output(From, Tag, Str, #st{io_buffering=Buffered,buffered=Buf0}=St) -> St#st{buffered=Buf} end. +do_output(stdout, Str, #st{job_name=undefined}) -> + io:put_chars(Str); do_output(stdout, Str0, #st{job_name=Name}) -> Str = io_lib:format("Testing ~s: ~s\n", [Name,Str0]), io:put_chars(Str); -- cgit v1.2.3 From e6c3f2c107366c12edcd7a9b26e08642501fc888 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 31 Oct 2012 16:27:19 +0100 Subject: Make sure that "Cover analysing..." is written to stdout If it is written with io:fwrite/2 it will be written to the unexpected_io log, where it will not be of any use. --- lib/test_server/src/test_server.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/test_server/src/test_server.erl b/lib/test_server/src/test_server.erl index 2955809b03..abc85364d0 100644 --- a/lib/test_server/src/test_server.erl +++ b/lib/test_server/src/test_server.erl @@ -442,7 +442,7 @@ do_cover_compile1([]) -> %% this is only recommended if the erlang node is being terminated %% after the test is completed. cover_analyse(Analyse,Modules,Stop) -> - io:fwrite("Cover analysing...\n",[]), + print(stdout, "Cover analysing...\n", []), DetailsFun = case Analyse of {details,Dir} -> -- cgit v1.2.3 From 983b1a407119f427a9203769bb94784b1bf0563b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Thu, 1 Nov 2012 12:24:28 +0100 Subject: Handle ct:abort_current_testcase/1 when executing parallel groups ct:abort_current_testcase/1 (which is a wrapper for the function with the same name in test_server_ctrl) would not work as expected when a group with parallel test cases was executing. Essentially, the abort_current_testcase message would be ignored until the group has finished and would then abort the end_per_group testcase for the group. Since there is no unique current testcase when a parallel group is executing, we must handle the abort_current_testcase message and return an error tuple. Also fix the bug that test_server_ctrl:abort_current_testcase/1 would always return 'ok'. --- lib/common_test/src/ct.erl | 3 ++- lib/common_test/test/ct_error_SUITE.erl | 9 +++++++-- .../ct_error_SUITE_data/error/test/misc_error_1_SUITE.erl | 12 ++++++++++-- lib/test_server/src/test_server_ctrl.erl | 8 ++++++-- 4 files changed, 25 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/common_test/src/ct.erl b/lib/common_test/src/ct.erl index 90e4e79ccf..6ecd0a022c 100644 --- a/lib/common_test/src/ct.erl +++ b/lib/common_test/src/ct.erl @@ -987,8 +987,9 @@ get_testdata(Key) -> end. %%%----------------------------------------------------------------- -%%% @spec abort_current_testcase(Reason) -> ok | {error,no_testcase_running} +%%% @spec abort_current_testcase(Reason) -> ok | {error,ErrorReason} %%% Reason = term() +%%% ErrorReason = no_testcase_running | parallel_group %%% %%% @doc

When calling this function, the currently executing test case will be aborted. %%% It is the user's responsibility to know for sure which test case is currently diff --git a/lib/common_test/test/ct_error_SUITE.erl b/lib/common_test/test/ct_error_SUITE.erl index eda98a1bf6..6d90b29f41 100644 --- a/lib/common_test/test/ct_error_SUITE.erl +++ b/lib/common_test/test/ct_error_SUITE.erl @@ -1404,7 +1404,7 @@ test_events(misc_errors) -> [ {?eh,start_logging,{'DEF','RUNDIR'}}, {?eh,test_start,{'DEF',{'START_TIME','LOGDIR'}}}, - {?eh,start_info,{1,1,7}}, + {?eh,start_info,{1,1,9}}, {?eh,tc_start,{misc_error_1_SUITE,ct_fail_1}}, {?eh,tc_done,{misc_error_1_SUITE,ct_fail_1, {failed,{error,{test_case_failed,{error,this_is_expected}}}}}}, @@ -1431,7 +1431,12 @@ test_events(misc_errors) -> {?eh,tc_start,{misc_error_1_SUITE,killed_by_signal_2}}, {?eh,tc_done,{misc_error_1_SUITE,killed_by_signal_2, {failed,testcase_aborted_or_killed}}}, - {?eh,test_stats,{0,7,{0,0}}}, + {parallel, + [{?eh,tc_start,{misc_error_1_SUITE,p1}}, + {?eh,tc_done,{misc_error_1_SUITE,p1,ok}}, + {?eh,tc_start,{misc_error_1_SUITE,p2}}, + {?eh,tc_done,{misc_error_1_SUITE,p2,ok}}]}, + {?eh,test_stats,{2,7,{0,0}}}, {?eh,test_done,{'DEF','STOP_TIME'}}, {?eh,stop_logging,[]} ]. diff --git a/lib/common_test/test/ct_error_SUITE_data/error/test/misc_error_1_SUITE.erl b/lib/common_test/test/ct_error_SUITE_data/error/test/misc_error_1_SUITE.erl index 99c3ed05ec..61f3fa7e59 100644 --- a/lib/common_test/test/ct_error_SUITE_data/error/test/misc_error_1_SUITE.erl +++ b/lib/common_test/test/ct_error_SUITE_data/error/test/misc_error_1_SUITE.erl @@ -96,7 +96,7 @@ end_per_testcase(_TestCase, _Config) -> %% N = integer() | forever %%-------------------------------------------------------------------- groups() -> - []. + [{p,[parallel],[p1,p2]}]. %%-------------------------------------------------------------------- %% Function: all() -> GroupsAndTestCases | {skip,Reason} @@ -107,7 +107,8 @@ groups() -> %%-------------------------------------------------------------------- all() -> [ct_fail_1, ct_fail_2, ct_fail_3, ts_fail_1, ts_fail_2, - killed_by_signal_1, killed_by_signal_2]. + killed_by_signal_1, killed_by_signal_2, + {group,p}]. ct_fail_1(_) -> ct:fail({error,this_is_expected}), @@ -152,3 +153,10 @@ killed_by_signal_2(_) -> end), ct:sleep(1000), exit(this_should_not_be_seen). + +p1(_) -> + {error,parallel_group} = ct:abort_current_testcase(aborted), + ok. + +p2(_) -> + receive after 1000 -> ok end. diff --git a/lib/test_server/src/test_server_ctrl.erl b/lib/test_server/src/test_server_ctrl.erl index 6ea69b5e58..fe9ee003d1 100644 --- a/lib/test_server/src/test_server_ctrl.erl +++ b/lib/test_server/src/test_server_ctrl.erl @@ -463,8 +463,7 @@ wait_finish() -> ok. abort_current_testcase(Reason) -> - controller_call({abort_current_testcase,Reason}), - ok. + controller_call({abort_current_testcase,Reason}). abort() -> OldTrap = process_flag(trap_exit, true), @@ -3705,6 +3704,11 @@ handle_io_and_exit_loop(_, [], Ok,Skip,Fail) -> handle_io_and_exits(Main, CurrPid, CaseNum, Mod, Func, Cases) -> receive + {abort_current_testcase=Tag,_Reason,From} -> + %% If a parallel group is executing, there is no unique + %% current test case, so we must generate an error. + From ! {self(),Tag,{error,parallel_group}}, + handle_io_and_exits(Main, CurrPid, CaseNum, Mod, Func, Cases); %% end of io session from test case executed by main process {finished,_,Main,CaseNum,Mod,Func,Result,_RetVal} -> test_server_io:print_buffered(CurrPid), -- cgit v1.2.3 From f816de97c1fdbb96ca09a8980dab32ad2e1785e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Wed, 7 Nov 2012 14:16:13 +0100 Subject: test_server_io: Correct a few comments --- lib/test_server/src/test_server_io.erl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/test_server/src/test_server_io.erl b/lib/test_server/src/test_server_io.erl index 7ec36d0c1f..e960b3087a 100644 --- a/lib/test_server/src/test_server_io.erl +++ b/lib/test_server/src/test_server_io.erl @@ -68,8 +68,8 @@ stop() -> %% Return a group leader (a process using the test_server_gl module). %% If Shared is true, the shared group leader is returned (suitable for %% running sequential test cases), otherwise a new group leader process -%% is spawned. Group leader processes will live until they are garbaged -%% collected by a call to gc/0. +%% is spawned. Group leader processes will live until the +%% 'test_server_io' process is stopped. get_gl(Shared) when is_boolean(Shared) -> req({get_gl,Shared}). @@ -95,7 +95,7 @@ start_transaction() -> %% end_transaction() %% %% End the transaction started by start_transaction/0. Subsequent calls to -%% print/3 will cause the message to be printed directory. +%% print/3 will cause the message to be printed directly. end_transaction() -> req({end_transaction,self()}). -- cgit v1.2.3