From c9ef7945d7c1621ba6d51bb24dc1853f47e30cc5 Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Sun, 2 Mar 2014 12:06:26 +0100 Subject: Introduce group name for skipped cases in events, hooks and overview log --- lib/common_test/src/ct_framework.erl | 36 +++++++++++------------------------- lib/common_test/src/ct_hooks.erl | 11 ++++++----- 2 files changed, 17 insertions(+), 30 deletions(-) (limited to 'lib/common_test/src') diff --git a/lib/common_test/src/ct_framework.erl b/lib/common_test/src/ct_framework.erl index 54510a657a..1358ad1f60 100644 --- a/lib/common_test/src/ct_framework.erl +++ b/lib/common_test/src/ct_framework.erl @@ -1277,13 +1277,13 @@ report(What,Data) -> ct_util:set_testdata({What,Data}), ok; tc_start -> - %% Data = {{Suite,Func},LogFileName} + %% Data = {{Suite,GroupName,Func},LogFileName} ct_event:sync_notify(#event{name=tc_logfile, node=node(), data=Data}), ok; tc_done -> - {_Suite,Case,Result} = Data, + {_Suite,_GroupName,Case,Result} = Data, case Result of {failed, _} -> ct_hooks:on_tc_fail(What, Data); @@ -1327,20 +1327,12 @@ report(What,Data) -> tc_user_skip -> %% test case or config function specified as skipped in testspec, %% or init config func for suite/group has returned {skip,Reason} - %% Data = {Suite,Case,Comment} | - %% {Suite,{GroupConfigFunc,GroupName},Comment} - {Func,Data1} = case Data of - {Suite,{ConfigFunc,undefined},Cmt} -> - {ConfigFunc,{Suite,ConfigFunc,Cmt}}; - {_,{ConfigFunc,_},_} -> {ConfigFunc,Data}; - {_,Case,_} -> {Case,Data} - end, - + %% Data = {Suite,GroupName,Func,Comment} ct_event:sync_notify(#event{name=tc_user_skip, node=node(), - data=Data1}), - ct_hooks:on_tc_skip(What, Data1), - + data=Data}), + ct_hooks:on_tc_skip(What, Data), + Func = element(3, Data), if Func /= init_per_suite, Func /= init_per_group, Func /= end_per_suite, Func /= end_per_group -> add_to_stats(user_skipped); @@ -1350,21 +1342,15 @@ report(What,Data) -> tc_auto_skip -> %% test case skipped because of error in config function, or %% config function skipped because of error in info function - %% Data = {Suite,Case,Comment} | - %% {Suite,{GroupConfigFunc,GroupName},Comment} - {Func,Data1} = case Data of - {Suite,{ConfigFunc,undefined},Cmt} -> - {ConfigFunc,{Suite,ConfigFunc,Cmt}}; - {_,{ConfigFunc,_},_} -> {ConfigFunc,Data}; - {_,Case,_} -> {Case,Data} - end, + %% Data = {Suite,GroupName,Func,Comment} + %% this test case does not have a log, so printouts %% from event handlers should end up in the main log ct_event:sync_notify(#event{name=tc_auto_skip, node=node(), - data=Data1}), - ct_hooks:on_tc_skip(What, Data1), - + data=Data}), + ct_hooks:on_tc_skip(What, Data), + Func = element(3, Data), if Func /= end_per_suite, Func /= end_per_group -> add_to_stats(auto_skipped); diff --git a/lib/common_test/src/ct_hooks.erl b/lib/common_test/src/ct_hooks.erl index e845e9e908..fa8d36392c 100644 --- a/lib/common_test/src/ct_hooks.erl +++ b/lib/common_test/src/ct_hooks.erl @@ -121,11 +121,12 @@ end_tc(_Mod, TC, Config, Result, _Return) -> call(fun call_generic/3, Result, [post_end_per_testcase, TC, Config], '$ct_no_change'). -on_tc_skip(How, {Suite, Case, Reason}) -> - call(fun call_cleanup/3, {How, Reason}, [on_tc_skip, Suite, Case]). +on_tc_skip(How, {Suite, GroupName, Case, Reason}) -> + call(fun call_cleanup/3, {How, Reason}, + [on_tc_skip, Suite, GroupName, Case]). -on_tc_fail(_How, {Suite, Case, Reason}) -> - call(fun call_cleanup/3, Reason, [on_tc_fail, Suite, Case]). +on_tc_fail(_How, {Suite, GroupName, Case, Reason}) -> + call(fun call_cleanup/3, Reason, [on_tc_fail, Suite, GroupName, Case]). %% ------------------------------------------------------------------------- %% Internal Functions @@ -245,7 +246,7 @@ scope([post_init_per_suite, SuiteName|_]) -> scope(init) -> none. -terminate_if_scope_ends(HookId, [on_tc_skip,_Suite,{end_per_group,Name}], +terminate_if_scope_ends(HookId, [on_tc_skip,_Suite,Name,end_per_group], Hooks) -> terminate_if_scope_ends(HookId, [post_end_per_group, Name], Hooks); terminate_if_scope_ends(HookId, [on_tc_skip,Suite,end_per_suite], Hooks) -> -- cgit v1.2.3 From ffa2475adee774d0fced95d47fffe4528d436dd0 Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Mon, 3 Mar 2014 21:45:34 +0100 Subject: Update event protocol and CT Hooks API --- lib/common_test/src/ct_framework.erl | 52 +++++++++++++++++++++++------------- lib/common_test/src/ct_hooks.erl | 13 ++++----- 2 files changed, 41 insertions(+), 24 deletions(-) (limited to 'lib/common_test/src') diff --git a/lib/common_test/src/ct_framework.erl b/lib/common_test/src/ct_framework.erl index 1358ad1f60..94de9a3425 100644 --- a/lib/common_test/src/ct_framework.erl +++ b/lib/common_test/src/ct_framework.erl @@ -1277,28 +1277,35 @@ report(What,Data) -> ct_util:set_testdata({What,Data}), ok; tc_start -> - %% Data = {{Suite,GroupName,Func},LogFileName} + %% Data = {Suite,{Func,GroupName}},LogFileName} + Data1 = case Data of + {{Suite,{Func,undefined}},LFN} -> {{Suite,Func},LFN}; + _ -> Data + end, ct_event:sync_notify(#event{name=tc_logfile, node=node(), - data=Data}), + data=Data1}), ok; tc_done -> - {_Suite,_GroupName,Case,Result} = Data, + {Suite,{Func,GrName},Result} = Data, + Data1 = if GrName == undefined -> {Suite,Func,Result}; + true -> Data + end, case Result of {failed, _} -> - ct_hooks:on_tc_fail(What, Data); + ct_hooks:on_tc_fail(What, Data1); {skipped,{failed,{_,init_per_testcase,_}}} -> - ct_hooks:on_tc_skip(tc_auto_skip, Data); + ct_hooks:on_tc_skip(tc_auto_skip, Data1); {skipped,{require_failed,_}} -> - ct_hooks:on_tc_skip(tc_auto_skip, Data); + ct_hooks:on_tc_skip(tc_auto_skip, Data1); {skipped,_} -> - ct_hooks:on_tc_skip(tc_user_skip, Data); + ct_hooks:on_tc_skip(tc_user_skip, Data1); {auto_skipped,_} -> - ct_hooks:on_tc_skip(tc_auto_skip, Data); + ct_hooks:on_tc_skip(tc_auto_skip, Data1); _Else -> ok end, - case {Case,Result} of + case {Func,Result} of {init_per_suite,_} -> ok; {end_per_suite,_} -> @@ -1327,12 +1334,17 @@ report(What,Data) -> tc_user_skip -> %% test case or config function specified as skipped in testspec, %% or init config func for suite/group has returned {skip,Reason} - %% Data = {Suite,GroupName,Func,Comment} + %% Data = {Suite,{Func,GroupName},Comment} + {Func,Data1} = case Data of + {Suite,{F,undefined},Comment} -> + {F,{Suite,F,Comment}}; + D = {_,{F,_},_} -> + {F,D} + end, ct_event:sync_notify(#event{name=tc_user_skip, node=node(), - data=Data}), - ct_hooks:on_tc_skip(What, Data), - Func = element(3, Data), + data=Data1}), + ct_hooks:on_tc_skip(What, Data1), if Func /= init_per_suite, Func /= init_per_group, Func /= end_per_suite, Func /= end_per_group -> add_to_stats(user_skipped); @@ -1342,15 +1354,19 @@ report(What,Data) -> tc_auto_skip -> %% test case skipped because of error in config function, or %% config function skipped because of error in info function - %% Data = {Suite,GroupName,Func,Comment} - + %% Data = {Suite,{Func,GroupName},Comment} + {Func,Data1} = case Data of + {Suite,{F,undefined},Comment} -> + {F,{Suite,F,Comment}}; + D = {_,{F,_},_} -> + {F,D} + end, %% this test case does not have a log, so printouts %% from event handlers should end up in the main log ct_event:sync_notify(#event{name=tc_auto_skip, node=node(), - data=Data}), - ct_hooks:on_tc_skip(What, Data), - Func = element(3, Data), + data=Data1}), + ct_hooks:on_tc_skip(What, Data1), if Func /= end_per_suite, Func /= end_per_group -> add_to_stats(auto_skipped); diff --git a/lib/common_test/src/ct_hooks.erl b/lib/common_test/src/ct_hooks.erl index fa8d36392c..2e667030a9 100644 --- a/lib/common_test/src/ct_hooks.erl +++ b/lib/common_test/src/ct_hooks.erl @@ -121,12 +121,13 @@ end_tc(_Mod, TC, Config, Result, _Return) -> call(fun call_generic/3, Result, [post_end_per_testcase, TC, Config], '$ct_no_change'). -on_tc_skip(How, {Suite, GroupName, Case, Reason}) -> - call(fun call_cleanup/3, {How, Reason}, - [on_tc_skip, Suite, GroupName, Case]). +%% Case = TestCase | {TestCase,GroupName} +on_tc_skip(How, {Suite, Case, Reason}) -> + call(fun call_cleanup/3, {How, Reason}, [on_tc_skip, Suite, Case]). -on_tc_fail(_How, {Suite, GroupName, Case, Reason}) -> - call(fun call_cleanup/3, Reason, [on_tc_fail, Suite, GroupName, Case]). +%% Case = TestCase | {TestCase,GroupName} +on_tc_fail(_How, {Suite, Case, Reason}) -> + call(fun call_cleanup/3, Reason, [on_tc_fail, Suite, Case]). %% ------------------------------------------------------------------------- %% Internal Functions @@ -246,7 +247,7 @@ scope([post_init_per_suite, SuiteName|_]) -> scope(init) -> none. -terminate_if_scope_ends(HookId, [on_tc_skip,_Suite,Name,end_per_group], +terminate_if_scope_ends(HookId, [on_tc_skip,_Suite,{end_per_group,Name}], Hooks) -> terminate_if_scope_ends(HookId, [post_end_per_group, Name], Hooks); terminate_if_scope_ends(HookId, [on_tc_skip,Suite,end_per_suite], Hooks) -> -- cgit v1.2.3