From afc49fa5c7b391f0b861e83f11fc6aa8d832b830 Mon Sep 17 00:00:00 2001 From: Michael Uvarov Date: Wed, 10 Dec 2014 15:46:58 +0100 Subject: [PATCH 01/10] Do not skip Cassandra MAM tests --- test.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test.config b/test.config index a6f9b52..6d04877 100644 --- a/test.config +++ b/test.config @@ -201,7 +201,7 @@ ]}. {mam, [ - {skipped_configurations, [ca]} +% {skipped_configurations, [ca]} ]}. %% vim: ft=erlang From 77dddfaaa3c63a7b88697b8bdad184f0aff01262 Mon Sep 17 00:00:00 2001 From: Michael Uvarov Date: Thu, 11 Dec 2014 12:20:04 +0100 Subject: [PATCH 02/10] Skip MAM tests unsupported by Cassadra back-end --- tests/mam_SUITE.erl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/mam_SUITE.erl b/tests/mam_SUITE.erl index 168a79a..4465145 100644 --- a/tests/mam_SUITE.erl +++ b/tests/mam_SUITE.erl @@ -178,15 +178,29 @@ tests() -> not is_skipped(C, G)]. groups() -> - [{full_group(C, G), Props, Tests} + [{full_group(C, G), Props, filter_tests(C, G, Tests)} || C <- configurations(), {G, Props, Tests} <- basic_groups(), not is_skipped(C, G)]. +filter_tests(C, G, Tests) -> + [Test || Test <- Tests, not is_test_skipped(C, G, Test)]. + is_skipped(odbc_mnesia_muc_cache, muc) -> false; is_skipped(odbc_mnesia_muc_cache, muc_with_pm) -> false; is_skipped(odbc_mnesia_muc_cache, muc_rsm) -> false; is_skipped(C, _) -> is_configuration_skipped(C). +is_test_skipped(ca, _, muc_querying_for_all_messages_with_jid) -> + true; % with_jid_not_supported +is_test_skipped(ca, _, querying_for_all_messages_with_jid) -> + true; % with_jid_not_supported +is_test_skipped(ca, _, pagination_offset5_opt_count) -> + true; % offset_not_supported +is_test_skipped(ca, _, pagination_offset5_opt_count_all) -> + true; % offset_not_supported +is_test_skipped(_C, _G, _Test) -> + false. + is_configuration_skipped(C) -> lists:member(C, skipped_configurations()). From ee6393ee439396fe57e8d1037675bd03a3246381 Mon Sep 17 00:00:00 2001 From: Michael Uvarov Date: Thu, 11 Dec 2014 14:37:01 +0100 Subject: [PATCH 03/10] Handle errors in mam_SUITE:init_per_group/2 --- tests/mam_SUITE.erl | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/tests/mam_SUITE.erl b/tests/mam_SUITE.erl index 4465145..7878d66 100644 --- a/tests/mam_SUITE.erl +++ b/tests/mam_SUITE.erl @@ -188,6 +188,7 @@ filter_tests(C, G, Tests) -> is_skipped(odbc_mnesia_muc_cache, muc) -> false; is_skipped(odbc_mnesia_muc_cache, muc_with_pm) -> false; is_skipped(odbc_mnesia_muc_cache, muc_rsm) -> false; +is_skipped(odbc_mnesia_muc_cache, _) -> true; is_skipped(C, _) -> is_configuration_skipped(C). is_test_skipped(ca, _, muc_querying_for_all_messages_with_jid) -> @@ -306,8 +307,8 @@ init_per_group(Group, Config) -> B = basic_group(Group), ct:pal("Init per group ~p; configuration ~p; basic group ~p", [Group, C, B]), - Config1 = init_modules(C, B, Config), - init_state(C, B, Config1). + Config1 = try_init_modules(C, B, Config), + try_init_state(C, B, Config1). end_per_group(Group, Config) -> C = configuration(Group), @@ -315,6 +316,26 @@ end_per_group(Group, Config) -> Config1 = end_state(C, B, Config), end_modules(C, B, Config1). +try_init_modules(C, B, Config) -> + try + init_modules(C, B, Config) + catch Class:Reason -> + Stacktrace = erlang:get_stacktrace(), + ct:pal("init_modules failed, configuration=~p, basic_group=~p, stacktrace=~p", + [C, B, Stacktrace]), + erlang:raise(Class, Reason, Stacktrace) + end. + +try_init_state(C, B, Config) -> + try + init_state(C, B, Config) + catch Class:Reason -> + Stacktrace = erlang:get_stacktrace(), + ct:pal("init_state failed, configuration=~p, basic_group=~p, stacktrace=~p", + [C, B, Stacktrace]), + erlang:raise(Class, Reason, Stacktrace) + end. + init_modules(C, muc_rsm, Config) -> init_modules(C, muc, Config); From 7992443ab2a16b1a7c550394d5cebf06c049b1dc Mon Sep 17 00:00:00 2001 From: Michael Uvarov Date: Thu, 11 Dec 2014 14:40:11 +0100 Subject: [PATCH 04/10] Run mam_SUITE only (TO BE REVERTED) --- default.spec | 29 ----------------------------- full.spec | 33 --------------------------------- 2 files changed, 62 deletions(-) diff --git a/default.spec b/default.spec index 43ee010..c7325df 100644 --- a/default.spec +++ b/default.spec @@ -8,36 +8,7 @@ %% For more info see: %% http://www.erlang.org/doc/apps/common_test/run_test_chapter.html#test_specifications -{suites, "tests", adhoc_SUITE}. -{suites, "tests", amp_SUITE}. -{suites, "tests", anonymous_SUITE}. -{suites, "tests", bosh_SUITE}. -{suites, "tests", carboncopy_SUITE}. -{suites, "tests", cluster_commands_SUITE}. -{suites, "tests", conf_reload_SUITE}. -{suites, "tests", connect_SUITE}. -{suites, "tests", ejabberdctl_SUITE}. -{suites, "tests", last_SUITE}. -{suites, "tests", login_SUITE}. {suites, "tests", mam_SUITE}. -{suites, "tests", metrics_api_SUITE}. -{suites, "tests", metrics_c2s_SUITE}. -{suites, "tests", metrics_roster_SUITE}. -{suites, "tests", metrics_register_SUITE}. -{suites, "tests", metrics_session_SUITE}. -{suites, "tests", muc_SUITE}. -{suites, "tests", offline_SUITE}. -{suites, "tests", presence_SUITE}. -{suites, "tests", privacy_SUITE}. -{suites, "tests", private_SUITE}. -{suites, "tests", s2s_SUITE}. -{suites, "tests", shared_roster_SUITE}. -{suites, "tests", sic_SUITE}. -{suites, "tests", sm_SUITE}. -{suites, "tests", system_monitor_SUITE}. -{suites, "tests", users_api_SUITE}. -{suites, "tests", vcard_simple_SUITE}. -{suites, "tests", websockets_SUITE}. {config, ["test.config"]}. {logdir, "ct_report"}. {ct_hooks, [ct_tty_hook, ct_mongoose_hook]}. diff --git a/full.spec b/full.spec index 0384f09..660a3e6 100644 --- a/full.spec +++ b/full.spec @@ -1,35 +1,2 @@ -{suites, "tests", anonymous_SUITE}. -{suites, "tests", bosh_SUITE}. -{suites, "tests", s2s_SUITE}. -%%{suites, "tests", snmp_SUITE}. -%%{suites, "tests", snmp_c2s_SUITE}. -%%{suites, "tests", snmp_register_SUITE}. -%%{suites, "tests", snmp_roster_SUITl}. -%%{suites, "tests", snmp_session_SUITE}. -%%{suites, "tests", snmp_table_SUITE}. - %% taken from default.spec -{suites, "tests", adhoc_SUITE}. -{suites, "tests", conf_reload_SUITE}. -{suites, "tests", ejabberdctl_SUITE}. -{suites, "tests", last_SUITE}. -{suites, "tests", login_SUITE}. -{suites, "tests", muc_SUITE}. {suites, "tests", mam_SUITE}. -{suites, "tests", offline_SUITE}. -{suites, "tests", presence_SUITE}. -{suites, "tests", privacy_SUITE}. -{suites, "tests", private_SUITE}. -{suites, "tests", sic_SUITE}. -{suites, "tests", users_api_SUITE}. -{suites, "tests", vcard_simple_SUITE}. -{suites, "tests", websockets_SUITE}. -{suites, "tests", metrics_api_SUITE}. -{suites, "tests", metrics_c2s_SUITE}. -{suites, "tests", metrics_roster_SUITE}. -{suites, "tests", metrics_register_SUITE}. -{suites, "tests", metrics_session_SUITE}. -{suites, "tests", system_monitor_SUITE}. -{suites, "tests", carboncopy_SUITE}. -{config, ["test.config"]}. -{logdir, "ct_report"}. From 0f59e797f91d5d5a5c4fe158b1be9969cdc8aa38 Mon Sep 17 00:00:00 2001 From: Michael Uvarov Date: Fri, 12 Dec 2014 11:41:49 +0100 Subject: [PATCH 05/10] Skip unsupported by Cassandra MAM back-end tests --- tests/mam_SUITE.erl | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/tests/mam_SUITE.erl b/tests/mam_SUITE.erl index 7878d66..b9e7a61 100644 --- a/tests/mam_SUITE.erl +++ b/tests/mam_SUITE.erl @@ -189,16 +189,24 @@ is_skipped(odbc_mnesia_muc_cache, muc) -> false; is_skipped(odbc_mnesia_muc_cache, muc_with_pm) -> false; is_skipped(odbc_mnesia_muc_cache, muc_rsm) -> false; is_skipped(odbc_mnesia_muc_cache, _) -> true; +is_skipped(ca, rsm) -> + true; %% only with_rsm group supported, mod_mam_con_ca_arch missing_with_jid is_skipped(C, _) -> is_configuration_skipped(C). -is_test_skipped(ca, _, muc_querying_for_all_messages_with_jid) -> - true; % with_jid_not_supported -is_test_skipped(ca, _, querying_for_all_messages_with_jid) -> - true; % with_jid_not_supported -is_test_skipped(ca, _, pagination_offset5_opt_count) -> - true; % offset_not_supported -is_test_skipped(ca, _, pagination_offset5_opt_count_all) -> - true; % offset_not_supported +is_test_skipped(ca, muc_rsm, muc_querying_for_all_messages_with_jid) -> + true; % mod_mam_muc_ca_arch with_jid_not_supported +is_test_skipped(ca, rsm, pagination_offset5_opt_count) -> + true; % mod_mam_con_ca_arch offset_not_supported +is_test_skipped(ca, with_rsm, pagination_offset5_opt_count) -> + true; % mod_mam_con_ca_arch offset_not_supported +is_test_skipped(ca, muc_rsm, pagination_offset5_opt_count) -> + true; % mod_mam_muc_ca_arch offset_not_supported +is_test_skipped(ca, rsm, pagination_offset5_opt_count_all) -> + true; % mod_mam_con_ca_arch offset_not_supported +is_test_skipped(ca, with_rsm, pagination_offset5_opt_count_all) -> + true; % mod_mam_con_ca_arch offset_not_supported +is_test_skipped(ca, muc_rsm, pagination_offset5_opt_count_all) -> + true; % mod_mam_muc_ca_arch offset_not_supported is_test_skipped(_C, _G, _Test) -> false. @@ -261,9 +269,11 @@ muc_cases() -> muc_rsm_cases() -> rsm_cases(). +%% RSM cases with filtering by countact jid with_rsm_cases() -> rsm_cases(). +%% RSM cases without filtering by countact jid rsm_cases() -> [pagination_first5, pagination_last5, From 5e8e50086bda7be9a26e9e77b2a09cdc32c19575 Mon Sep 17 00:00:00 2001 From: Michael Uvarov Date: Fri, 12 Dec 2014 16:12:44 +0100 Subject: [PATCH 06/10] Allow to fold the travis log --- default.spec | 2 +- src/ct_travis_hook.erl | 108 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+), 1 deletion(-) create mode 100644 src/ct_travis_hook.erl diff --git a/default.spec b/default.spec index c7325df..087e8cd 100644 --- a/default.spec +++ b/default.spec @@ -11,6 +11,6 @@ {suites, "tests", mam_SUITE}. {config, ["test.config"]}. {logdir, "ct_report"}. -{ct_hooks, [ct_tty_hook, ct_mongoose_hook]}. +{ct_hooks, [ct_tty_hook, ct_mongoose_hook, ct_travis_hook]}. %%To enable printing group and case enters on server side %%{ct_hooks, [{ct_tty_hook, [print_group, print_case]}]}. diff --git a/src/ct_travis_hook.erl b/src/ct_travis_hook.erl new file mode 100644 index 0000000..5007964 --- /dev/null +++ b/src/ct_travis_hook.erl @@ -0,0 +1,108 @@ +%%% @doc Common Test Example Common Test Hook module. +-module(ct_travis_hook). + +%% Callbacks +-export([id/1]). +-export([init/2]). + +-export([pre_init_per_suite/3]). +-export([post_init_per_suite/4]). +-export([pre_end_per_suite/3]). +-export([post_end_per_suite/4]). + +-export([pre_init_per_group/3]). +-export([post_init_per_group/4]). +-export([pre_end_per_group/3]). +-export([post_end_per_group/4]). + +-export([pre_init_per_testcase/3]). +-export([post_end_per_testcase/4]). + +-export([on_tc_fail/3]). +-export([on_tc_skip/3]). + +-export([terminate/1]). + +-record(state, { log_fd }). + +%% @doc Return a unique id for this CTH. +id(Opts) -> + ct_travis_hook. + +%% @doc Always called before any other callback function. Use this to initiate +%% any common state. +init(Id, Opts) -> + ct:pal("Init ct_travis_hook", []), + {ok, FD} = file:open("/tmp/ct_travis_hook.log", [append, write]), + {ok, #state{log_fd=FD}}. + +%% @doc Called before init_per_suite is called. +pre_init_per_suite(Suite,Config,State) -> + {Config, fold_start(Suite, State)}. + +%% @doc Called after init_per_suite. +post_init_per_suite(Suite,Config,Return,State) -> + {Return, State}. + +%% @doc Called before end_per_suite. +pre_end_per_suite(Suite,Config,State) -> + {Config, State}. + +%% @doc Called after end_per_suite. +post_end_per_suite(Suite,Config,Return,State) -> + {Return, fold_end(Suite, State)}. + +%% @doc Called before each init_per_group. +pre_init_per_group(Group,Config,State) -> + {Config, fold_start(Group, State)}. + +%% @doc Called after each init_per_group. +post_init_per_group(Group,Config,Return,State) -> + {Return, State}. + +%% @doc Called after each end_per_group. +pre_end_per_group(Group,Config,State) -> + {Config, State}. + +%% @doc Called after each end_per_group. +post_end_per_group(Group,Config,Return,State) -> + {Return, fold_end(Group, State)}. + +%% @doc Called before each test case. +pre_init_per_testcase(TC,Config,State) -> + {Config, fold_start(TC, State)}. + +%% @doc Called after each test case. +post_end_per_testcase(TC,Config,Return,State) -> + {Return, fold_end(TC, State)}. + +%% @doc Called after post_init_per_suite, post_end_per_suite, post_init_per_group, +%% post_end_per_group and post_end_per_testcase if the suite, group or test case failed. +on_tc_fail(TC, Reason, State) -> + State. + +%% @doc Called when a test case is skipped by either user action +%% or due to an init function failing. +on_tc_skip(TC, Reason, State) -> + State. + +%% @doc Called when the scope of the CTH is done +terminate(State) -> + ok. + +%% -------------------------------------------------------------------- +%% Private + +%% Same as: +%% echo -en "travis_fold:start:Name\\r" +%% echo "Name" +fold_start(Name, State=#state{log_fd=FD}) -> + io:format(FD, "travis_fold:start:~p\r~p~n", [Name, Name]), + State. + +%% Same as: +%% echo -en "travis_fold:end:Name\\r" +fold_end(Name, State=#state{log_fd=FD}) -> + io:format(FD, "travis_fold:end:~p\r", [Name]), + State. + From 6ff14407af38b44724b2975d7ef1d344da1f9663 Mon Sep 17 00:00:00 2001 From: Michael Uvarov Date: Fri, 12 Dec 2014 16:50:20 +0100 Subject: [PATCH 07/10] Add type prefix for travis log labels --- src/ct_travis_hook.erl | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/ct_travis_hook.erl b/src/ct_travis_hook.erl index 5007964..8c89b29 100644 --- a/src/ct_travis_hook.erl +++ b/src/ct_travis_hook.erl @@ -38,7 +38,7 @@ init(Id, Opts) -> %% @doc Called before init_per_suite is called. pre_init_per_suite(Suite,Config,State) -> - {Config, fold_start(Suite, State)}. + {Config, fold_start(suite, Suite, State)}. %% @doc Called after init_per_suite. post_init_per_suite(Suite,Config,Return,State) -> @@ -50,11 +50,11 @@ pre_end_per_suite(Suite,Config,State) -> %% @doc Called after end_per_suite. post_end_per_suite(Suite,Config,Return,State) -> - {Return, fold_end(Suite, State)}. + {Return, fold_end(suite, Suite, State)}. %% @doc Called before each init_per_group. pre_init_per_group(Group,Config,State) -> - {Config, fold_start(Group, State)}. + {Config, fold_start(group, Group, State)}. %% @doc Called after each init_per_group. post_init_per_group(Group,Config,Return,State) -> @@ -66,15 +66,15 @@ pre_end_per_group(Group,Config,State) -> %% @doc Called after each end_per_group. post_end_per_group(Group,Config,Return,State) -> - {Return, fold_end(Group, State)}. + {Return, fold_end(group, Group, State)}. %% @doc Called before each test case. pre_init_per_testcase(TC,Config,State) -> - {Config, fold_start(TC, State)}. + {Config, fold_start(test, TC, State)}. %% @doc Called after each test case. post_end_per_testcase(TC,Config,Return,State) -> - {Return, fold_end(TC, State)}. + {Return, fold_end(test, TC, State)}. %% @doc Called after post_init_per_suite, post_end_per_suite, post_init_per_group, %% post_end_per_group and post_end_per_testcase if the suite, group or test case failed. @@ -96,13 +96,16 @@ terminate(State) -> %% Same as: %% echo -en "travis_fold:start:Name\\r" %% echo "Name" -fold_start(Name, State=#state{log_fd=FD}) -> - io:format(FD, "travis_fold:start:~p\r~p~n", [Name, Name]), +fold_start(Type, Name, State=#state{log_fd=FD}) -> + io:format(FD, "travis_fold:start:~s~p\r~p~n", [print_type(Type), Name, Name]), State. %% Same as: %% echo -en "travis_fold:end:Name\\r" -fold_end(Name, State=#state{log_fd=FD}) -> - io:format(FD, "travis_fold:end:~p\r", [Name]), +fold_end(Type, Name, State=#state{log_fd=FD}) -> + io:format(FD, "travis_fold:end:~s~p\r", [print_type(Type), Name]), State. +print_type(suite) -> "s."; +print_type(group) -> "g."; +print_type(test) -> "t.". From e14d6178c67db0fbb0a360608d3e62bbbe05d703 Mon Sep 17 00:00:00 2001 From: Michael Uvarov Date: Fri, 12 Dec 2014 17:25:14 +0100 Subject: [PATCH 08/10] Print if test failed --- src/ct_travis_hook.erl | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/ct_travis_hook.erl b/src/ct_travis_hook.erl index 8c89b29..be8abf9 100644 --- a/src/ct_travis_hook.erl +++ b/src/ct_travis_hook.erl @@ -50,7 +50,7 @@ pre_end_per_suite(Suite,Config,State) -> %% @doc Called after end_per_suite. post_end_per_suite(Suite,Config,Return,State) -> - {Return, fold_end(suite, Suite, State)}. + {Return, fold_end(suite, Suite, Return, State)}. %% @doc Called before each init_per_group. pre_init_per_group(Group,Config,State) -> @@ -66,7 +66,7 @@ pre_end_per_group(Group,Config,State) -> %% @doc Called after each end_per_group. post_end_per_group(Group,Config,Return,State) -> - {Return, fold_end(group, Group, State)}. + {Return, fold_end(group, Group, Return, State)}. %% @doc Called before each test case. pre_init_per_testcase(TC,Config,State) -> @@ -74,7 +74,7 @@ pre_init_per_testcase(TC,Config,State) -> %% @doc Called after each test case. post_end_per_testcase(TC,Config,Return,State) -> - {Return, fold_end(test, TC, State)}. + {Return, fold_end(test, TC, Return, State)}. %% @doc Called after post_init_per_suite, post_end_per_suite, post_init_per_group, %% post_end_per_group and post_end_per_testcase if the suite, group or test case failed. @@ -102,10 +102,17 @@ fold_start(Type, Name, State=#state{log_fd=FD}) -> %% Same as: %% echo -en "travis_fold:end:Name\\r" -fold_end(Type, Name, State=#state{log_fd=FD}) -> - io:format(FD, "travis_fold:end:~s~p\r", [print_type(Type), Name]), +fold_end(Type, Name, Return, State=#state{log_fd=FD}) -> + io:format(FD, "travis_fold:end:~s~p\r~s", [print_type(Type), Name, print_return(Return)]), State. print_type(suite) -> "s."; print_type(group) -> "g."; print_type(test) -> "t.". + +print_return({skip, Reason}) -> + io_lib:format("Skipped ~p~n", [Reason]); +print_return({fail, Reason}) -> + io_lib:format("Failed ~p~n", [Reason]); +print_return(_) -> + "". From 9b7f94fcd0b47a9b96223aab09aab45f4b8844cf Mon Sep 17 00:00:00 2001 From: Michael Uvarov Date: Fri, 12 Dec 2014 17:37:49 +0100 Subject: [PATCH 09/10] Append a test number to log labels --- src/ct_travis_hook.erl | 49 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/src/ct_travis_hook.erl b/src/ct_travis_hook.erl index be8abf9..a798829 100644 --- a/src/ct_travis_hook.erl +++ b/src/ct_travis_hook.erl @@ -23,7 +23,7 @@ -export([terminate/1]). --record(state, { log_fd }). +-record(state, { log_fd, test_n, group_test_n }). %% @doc Return a unique id for this CTH. id(Opts) -> @@ -38,7 +38,8 @@ init(Id, Opts) -> %% @doc Called before init_per_suite is called. pre_init_per_suite(Suite,Config,State) -> - {Config, fold_start(suite, Suite, State)}. + State2 = reset_test_n(State), + {Config, fold_start(suite, Suite, State2)}. %% @doc Called after init_per_suite. post_init_per_suite(Suite,Config,Return,State) -> @@ -54,7 +55,9 @@ post_end_per_suite(Suite,Config,Return,State) -> %% @doc Called before each init_per_group. pre_init_per_group(Group,Config,State) -> - {Config, fold_start(group, Group, State)}. + State2 = set_group_test_n(State), + State3 = fold_start(group, Group, State2), + {Config, State3}. %% @doc Called after each init_per_group. post_init_per_group(Group,Config,Return,State) -> @@ -74,7 +77,9 @@ pre_init_per_testcase(TC,Config,State) -> %% @doc Called after each test case. post_end_per_testcase(TC,Config,Return,State) -> - {Return, fold_end(test, TC, Return, State)}. + State2 = fold_end(test, TC, Return, State), + State3 = inc_test_n(State2), + {Return, State3}. %% @doc Called after post_init_per_suite, post_end_per_suite, post_init_per_group, %% post_end_per_group and post_end_per_testcase if the suite, group or test case failed. @@ -97,13 +102,20 @@ terminate(State) -> %% echo -en "travis_fold:start:Name\\r" %% echo "Name" fold_start(Type, Name, State=#state{log_fd=FD}) -> - io:format(FD, "travis_fold:start:~s~p\r~p~n", [print_type(Type), Name, Name]), + STestN = get_and_print_n(Type, State), + SType = print_type(Type), + io:format(FD, "travis_fold:start:~s~p.~s\r~p~n", + [SType, Name, STestN, Name]), State. %% Same as: %% echo -en "travis_fold:end:Name\\r" fold_end(Type, Name, Return, State=#state{log_fd=FD}) -> - io:format(FD, "travis_fold:end:~s~p\r~s", [print_type(Type), Name, print_return(Return)]), + STestN = get_and_print_n(Type, State), + SType = print_type(Type), + SReturn = print_return(Return), + io:format(FD, "travis_fold:end:~s~p.~s\r~s", + [SType, Name, STestN, SReturn]), State. print_type(suite) -> "s."; @@ -116,3 +128,28 @@ print_return({fail, Reason}) -> io_lib:format("Failed ~p~n", [Reason]); print_return(_) -> "". + +inc_test_n(State=#state{test_n=TestN}) -> + State#state{test_n=TestN+1}. + +reset_test_n(State=#state{test_n=TestN}) -> + State#state{test_n=1}. + +set_group_test_n(State=#state{test_n=TestN}) -> + State#state{group_test_n=TestN}. + +get_and_print_n(Type, State) -> + TestN = get_test_n(Type, State), + print_test_n(Type, TestN). + +get_test_n(test, State=#state{test_n=TestN}) -> + TestN; +get_test_n(group, State=#state{group_test_n=TestN}) -> + TestN; +get_test_n(suite, State=#state{}) -> + 1. + +print_test_n(suite, _TestN) -> + ""; % do not print for suites, because TestN is always 1 +print_test_n(_Type, TestN) -> + integer_to_list(TestN). From ca6f6d963015243fd5919af621e119573cc392d2 Mon Sep 17 00:00:00 2001 From: Michael Uvarov Date: Sat, 13 Dec 2014 14:50:41 +0100 Subject: [PATCH 10/10] Add newline in ct_travis_hook:print_return/1 --- src/ct_travis_hook.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ct_travis_hook.erl b/src/ct_travis_hook.erl index a798829..79e6f98 100644 --- a/src/ct_travis_hook.erl +++ b/src/ct_travis_hook.erl @@ -123,9 +123,9 @@ print_type(group) -> "g."; print_type(test) -> "t.". print_return({skip, Reason}) -> - io_lib:format("Skipped ~p~n", [Reason]); + io_lib:format("~nSkipped ~p~n", [Reason]); print_return({fail, Reason}) -> - io_lib:format("Failed ~p~n", [Reason]); + io_lib:format("~nFailed ~p~n", [Reason]); print_return(_) -> "".