From 7a6607d6326d93a92d701d0b505a48f32ed68d10 Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Tue, 14 Sep 2010 10:46:02 +0200 Subject: Fix so that groups can return external test cases, i.e. groups() -> [{test, [sequence], [{other_suite, all}]}]. --- lib/common_test/src/ct_framework.erl | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/common_test') diff --git a/lib/common_test/src/ct_framework.erl b/lib/common_test/src/ct_framework.erl index f2ca023cff..3bbb338121 100644 --- a/lib/common_test/src/ct_framework.erl +++ b/lib/common_test/src/ct_framework.erl @@ -770,6 +770,11 @@ find(Mod, Name, TCs, [TC | Gs], Known, Defs, false) when is_atom(TC) -> find(Mod, Name, TCs, [TC | Gs], Known, Defs, true) when is_atom(TC) -> [TC | find(Mod, Name, TCs, Gs, Known, Defs, true)]; +find(Mod, Name, TCs, [{ExternalTC, Case} = TC | Gs], Known, Defs, true) + when is_atom(ExternalTC), + is_atom(Case) -> + [TC | find(Mod, Name, TCs, Gs, Known, Defs, true)]; + find(Mod, _Name, _TCs, [BadTerm | _Gs], Known, _Defs, _Found) -> Where = if length(Known) == 0 -> atom_to_list(Mod)++":groups/0"; -- cgit v1.2.3 From 418f30e5c2f64802075c1bc3188935aa91cd8d4e Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Fri, 1 Oct 2010 17:30:36 +0200 Subject: Refactor code to make it easier to debug --- lib/common_test/src/ct_framework.erl | 46 ++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'lib/common_test') diff --git a/lib/common_test/src/ct_framework.erl b/lib/common_test/src/ct_framework.erl index 3bbb338121..dde9739dc6 100644 --- a/lib/common_test/src/ct_framework.erl +++ b/lib/common_test/src/ct_framework.erl @@ -938,27 +938,7 @@ get_all(Mod, ConfTests) -> [{?MODULE,error_in_suite,[[{error,What}]]}]; SeqsAndTCs -> %% expand group references in all() using ConfTests - Expand = - fun({group,Name}) -> - FindConf = - fun({conf,Props,_,_,_}) -> - case proplists:get_value(name, Props) of - Name -> true; - _ -> false - end - end, - case lists:filter(FindConf, ConfTests) of - [ConfTest|_] -> - ConfTest; - [] -> - E = "Invalid reference to group "++ - atom_to_list(Name)++" in "++ - atom_to_list(Mod)++":all/0", - throw({error,list_to_atom(E)}) - end; - (SeqOrTC) -> SeqOrTC - end, - case catch lists:map(Expand, SeqsAndTCs) of + case catch expand_groups(SeqsAndTCs, ConfTests, Mod) of {error,_} = Error -> [{?MODULE,error_in_suite,[[Error]]}]; Tests -> @@ -973,6 +953,30 @@ get_all(Mod, ConfTests) -> [{?MODULE,error_in_suite,[[{error,Reason}]]}] end. +expand_groups([H | T], ConfTests, Mod) -> + [expand_groups(H, ConfTests, Mod) | expand_groups(T, ConfTests, Mod)]; +expand_groups([], _ConfTests, _Mod) -> + []; +expand_groups({group,Name}, ConfTests, Mod) -> + FindConf = + fun({conf,Props,_,_,_}) -> + case proplists:get_value(name, Props) of + Name -> true; + _ -> false + end + end, + case lists:filter(FindConf, ConfTests) of + [ConfTest|_] -> + expand_groups(ConfTest, ConfTests, Mod); + [] -> + E = "Invalid reference to group "++ + atom_to_list(Name)++" in "++ + atom_to_list(Mod)++":all/0", + throw({error,list_to_atom(E)}) + end; +expand_groups(SeqOrTC, _ConfTests, _Mod) -> + SeqOrTC. + %%!============================================================ %%! The support for sequences by means of using sequences/0 -- cgit v1.2.3 From 7629d083e321a964d3f1cd05b5af746d62dfb5fb Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Fri, 1 Oct 2010 17:31:02 +0200 Subject: Add support for external groups. --- lib/common_test/src/ct_framework.erl | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'lib/common_test') diff --git a/lib/common_test/src/ct_framework.erl b/lib/common_test/src/ct_framework.erl index dde9739dc6..1c4ee7bd49 100644 --- a/lib/common_test/src/ct_framework.erl +++ b/lib/common_test/src/ct_framework.erl @@ -760,20 +760,28 @@ find(Mod, Name, all, [{Name1,Props,Tests} | Gs], Known, Defs, true) find(Mod, Name, TCs, [{group,Name1} | Gs], Known, Defs, Found) when is_atom(Name1) -> find(Mod, Name, TCs, [expand(Mod, Name1, Defs) | Gs], Known, Defs, Found); -find(Mod, Name, TCs, [{Name1,Tests} | Gs], Known, Defs, Found) +find(Mod, Name, TCs, [{Name1,Tests} | Gs], Known, Defs, false) when is_atom(Name1), is_list(Tests) -> - find(Mod, Name, TCs, [{Name1,[],Tests} | Gs], Known, Defs, Found); + find(Mod, Name, TCs, [{Name1,[],Tests} | Gs], Known, Defs, false); + +find(Mod, Name, TCs, [{Name1,Groups} | Gs], Known, Defs, true) + when is_atom(Name1), is_list(Groups) -> + ExternalDefs = Name1:groups(), + ExternalGroup = proplists:get_value(group, Groups), + ExternalTCs = find(Name1, ExternalGroup, TCs, Groups, + [], ExternalDefs, false), + ExternalTCs ++ find(Mod, Name, TCs, Gs, Known, Defs, true); find(Mod, Name, TCs, [TC | Gs], Known, Defs, false) when is_atom(TC) -> find(Mod, Name, TCs, Gs, Known, Defs, false); find(Mod, Name, TCs, [TC | Gs], Known, Defs, true) when is_atom(TC) -> - [TC | find(Mod, Name, TCs, Gs, Known, Defs, true)]; + [{Mod, TC} | find(Mod, Name, TCs, Gs, Known, Defs, true)]; -find(Mod, Name, TCs, [{ExternalTC, Case} = TC | Gs], Known, Defs, true) +find(Mod, Name, TCs, [{ExternalTC, Case} = TC | Gs], Known, Defs, Found) when is_atom(ExternalTC), is_atom(Case) -> - [TC | find(Mod, Name, TCs, Gs, Known, Defs, true)]; + [TC | find(Mod, Name, TCs, Gs, Known, Defs, Found)]; find(Mod, _Name, _TCs, [BadTerm | _Gs], Known, _Defs, _Found) -> Where = if length(Known) == 0 -> -- cgit v1.2.3 From a65da791a0ad23805ab756c25df0220b47b740a2 Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Tue, 5 Oct 2010 17:50:58 +0200 Subject: Fix bug when groups refer to groups in the groups/0 function --- lib/common_test/src/ct_framework.erl | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) (limited to 'lib/common_test') diff --git a/lib/common_test/src/ct_framework.erl b/lib/common_test/src/ct_framework.erl index 1c4ee7bd49..b554749f7a 100644 --- a/lib/common_test/src/ct_framework.erl +++ b/lib/common_test/src/ct_framework.erl @@ -694,12 +694,12 @@ get_suite(Mod, Group={conf,Props,_Init,TCs,_End}) -> %% init/end functions for top groups will be executed case catch proplists:get_value(name, element(2, hd(ConfTests))) of Name -> % top group - ConfTests; + delete_subs(ConfTests, ConfTests); _ -> [] end; false -> - ConfTests + delete_subs(ConfTests, ConfTests) end end; _ -> @@ -716,7 +716,22 @@ get_suite(Mod, Name) -> find_groups(Mod, Name, TCs, GroupDefs) -> Found = find(Mod, Name, TCs, GroupDefs, [], GroupDefs, false), Trimmed = trim(Found), - delete_subs(Trimmed, Trimmed). + %% I cannot find a reason to why this function is called, + %% It deletes any group which is referenced in any other + %% group. i.e. + %% groups() -> + %% [{test, [], [testcase1]}, + %% {testcases, [], [{group, test}]}]. + %% Would be changed to + %% groups() -> + %% [{testcases, [], [testcase1]}]. + %% instead of what I believe is correct: + %% groups() -> + %% [{test, [], [testcase1]}, + %% {testcases, [], [testcase1]}]. + %% Have to double check with peppe + delete_subs(Trimmed, Trimmed), + Trimmed. find(Mod, all, _TCs, [{Name,Props,Tests} | Gs], Known, Defs, _) -> cyclic_test(Mod, Name, Known), @@ -800,7 +815,7 @@ find(_Mod, _Name, _TCs, [], _Known, _Defs, false) -> find(_Mod, _Name, _TCs, [], _Known, _Defs, _Found) -> []. -delete_subs([Conf | Confs], All) -> +delete_subs([{conf, _,_,_,_} = Conf | Confs], All) -> All1 = delete_conf(Conf, All), case is_sub(Conf, All1) of true -> @@ -808,7 +823,8 @@ delete_subs([Conf | Confs], All) -> false -> delete_subs(Confs, All) end; - +delete_subs([_Else | Confs], All) -> + delete_subs(Confs, All); delete_subs([], All) -> All. @@ -900,7 +916,9 @@ make_all_conf(Mod) -> [] -> {error,{invalid_group_spec,Mod}}; ConfTests -> - [{conf,Props,Init,all,End} || {conf,Props,Init,_,End} <- ConfTests] + [{conf,Props,Init,all,End} || + {conf,Props,Init,_,End} + <- delete_subs(ConfTests, ConfTests)] end end. @@ -950,7 +968,7 @@ get_all(Mod, ConfTests) -> {error,_} = Error -> [{?MODULE,error_in_suite,[[Error]]}]; Tests -> - Tests + delete_subs(Tests, Tests) end end; Skip = {skip,_Reason} -> -- cgit v1.2.3 From 96a540b6b219290a8248ef25ec23c1d331f8e953 Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Mon, 6 Dec 2010 10:57:40 +0100 Subject: Add possibility to get all testdata --- lib/common_test/src/ct_util.erl | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/common_test') diff --git a/lib/common_test/src/ct_util.erl b/lib/common_test/src/ct_util.erl index b5ab4cbb6e..1b60820565 100644 --- a/lib/common_test/src/ct_util.erl +++ b/lib/common_test/src/ct_util.erl @@ -268,6 +268,9 @@ loop(Mode,TestData,StartDir) -> TestData1 = lists:keydelete(Key,1,TestData), return(From,ok), loop(Mode,[New|TestData1],StartDir); + {{get_testdata, all}, From} -> + return(From, TestData), + loop(From, TestData, StartDir); {{get_testdata,Key},From} -> case lists:keysearch(Key,1,TestData) of {value,{Key,Val}} -> -- cgit v1.2.3 From ab085b4bbdefd42b456f03dee47f6c51059a8192 Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Tue, 14 Dec 2010 10:28:27 +0100 Subject: Change format of remote groups to {group, Module, GroupName}, note that this is an unsupported feature --- lib/common_test/src/ct_framework.erl | 37 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'lib/common_test') diff --git a/lib/common_test/src/ct_framework.erl b/lib/common_test/src/ct_framework.erl index b554749f7a..3050aec0c5 100644 --- a/lib/common_test/src/ct_framework.erl +++ b/lib/common_test/src/ct_framework.erl @@ -733,7 +733,8 @@ find_groups(Mod, Name, TCs, GroupDefs) -> delete_subs(Trimmed, Trimmed), Trimmed. -find(Mod, all, _TCs, [{Name,Props,Tests} | Gs], Known, Defs, _) -> +find(Mod, all, _TCs, [{Name,Props,Tests} | Gs], Known, Defs, _) + when is_atom(Name), is_list(Props), is_list(Tests) -> cyclic_test(Mod, Name, Known), [make_conf(Mod, Name, Props, find(Mod, all, all, Tests, [Name | Known], Defs, true)) | @@ -755,9 +756,8 @@ find(Mod, Name, TCs, [{Name,Props,Tests} | _Gs], Known, Defs, false) find(Mod, Name, TCs, [{Name1,Props,Tests} | Gs], Known, Defs, false) when is_atom(Name1), is_list(Props), is_list(Tests) -> cyclic_test(Mod, Name1, Known), - [make_conf(Mod, Name1, Props, - find(Mod, Name, TCs, Tests, [Name1 | Known], Defs, false)) | - find(Mod, Name, TCs, Gs, [], Defs, false)]; + find(Mod, Name, TCs, Tests, [Name1 | Known], Defs, false) ++ + find(Mod, Name, TCs, Gs, [], Defs, false); find(Mod, Name, _TCs, [{Name,_Props,_Tests} | _Gs], _Known, _Defs, true) when is_atom(Name) -> @@ -772,31 +772,32 @@ find(Mod, Name, all, [{Name1,Props,Tests} | Gs], Known, Defs, true) find(Mod, Name, all, Tests, [Name1 | Known], Defs, true)) | find(Mod, Name, all, Gs, [], Defs, true)]; -find(Mod, Name, TCs, [{group,Name1} | Gs], Known, Defs, Found) when is_atom(Name1) -> +find(Mod, Name, TCs, [{group,Name1} | Gs], Known, Defs, Found) + when is_atom(Name1) -> find(Mod, Name, TCs, [expand(Mod, Name1, Defs) | Gs], Known, Defs, Found); -find(Mod, Name, TCs, [{Name1,Tests} | Gs], Known, Defs, false) - when is_atom(Name1), is_list(Tests) -> - find(Mod, Name, TCs, [{Name1,[],Tests} | Gs], Known, Defs, false); +%% Undocumented remote group feature, use with caution +find(Mod, Name, TCs, [{group, ExtMod, ExtGrp} | Gs], Known, Defs, true) + when is_atom(ExtMod), is_atom(ExtGrp) -> + ExternalDefs = ExtMod:groups(), + ExternalTCs = find(ExtMod, ExtGrp, TCs, [{group, ExtGrp}], + [], ExternalDefs, false), + ExternalTCs ++ find(Mod, Name, TCs, Gs, Known, Defs, true); -find(Mod, Name, TCs, [{Name1,Groups} | Gs], Known, Defs, true) - when is_atom(Name1), is_list(Groups) -> - ExternalDefs = Name1:groups(), - ExternalGroup = proplists:get_value(group, Groups), - ExternalTCs = find(Name1, ExternalGroup, TCs, Groups, - [], ExternalDefs, false), - ExternalTCs ++ find(Mod, Name, TCs, Gs, Known, Defs, true); +find(Mod, Name, TCs, [{Name1,Tests} | Gs], Known, Defs, Found) + when is_atom(Name1), is_list(Tests) -> + find(Mod, Name, TCs, [{Name1,[],Tests} | Gs], Known, Defs, Found); -find(Mod, Name, TCs, [TC | Gs], Known, Defs, false) when is_atom(TC) -> +find(Mod, Name, TCs, [_TC | Gs], Known, Defs, false) -> find(Mod, Name, TCs, Gs, Known, Defs, false); find(Mod, Name, TCs, [TC | Gs], Known, Defs, true) when is_atom(TC) -> [{Mod, TC} | find(Mod, Name, TCs, Gs, Known, Defs, true)]; -find(Mod, Name, TCs, [{ExternalTC, Case} = TC | Gs], Known, Defs, Found) +find(Mod, Name, TCs, [{ExternalTC, Case} = TC | Gs], Known, Defs, true) when is_atom(ExternalTC), is_atom(Case) -> - [TC | find(Mod, Name, TCs, Gs, Known, Defs, Found)]; + [TC | find(Mod, Name, TCs, Gs, Known, Defs, true)]; find(Mod, _Name, _TCs, [BadTerm | _Gs], Known, _Defs, _Found) -> Where = if length(Known) == 0 -> -- cgit v1.2.3 From ae7e427471b4798a94bf030b3261a46a7df898df Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Wed, 9 Feb 2011 19:05:29 +0100 Subject: Rename Suite Callback to Common Test Hook --- lib/common_test/doc/src/ct_junit_report.xml | 109 ---------------------------- 1 file changed, 109 deletions(-) delete mode 100644 lib/common_test/doc/src/ct_junit_report.xml (limited to 'lib/common_test') diff --git a/lib/common_test/doc/src/ct_junit_report.xml b/lib/common_test/doc/src/ct_junit_report.xml deleted file mode 100644 index 49a40cc1de..0000000000 --- a/lib/common_test/doc/src/ct_junit_report.xml +++ /dev/null @@ -1,109 +0,0 @@ - - - -
-ct_junit_report - - -1 - - - -A -ct_junit_report.xml
-ct_junit_report -Common Test Framework functions handling test specifications. - -

Common Test Framework functions handling test specifications.

- -

This module creates a junit report of the test run if plugged in - as a suite_callback.

- - -init(Opts) -> term() - - - - - - -post_end_group(Group, Config, State) -> term() - - - - - - -post_end_suite(Suite, Config, State) -> term() - - - - - - -post_end_tc(TC, Config, State) -> term() - - - - - - -post_init_group(Group, Config, State) -> term() - - - - - - -post_init_suite(Suite, Config, State) -> term() - - - - - - -pre_end_group(Group, Config, State) -> term() - - - - - - -pre_end_suite(Suite, Config, State) -> term() - - - - - - -pre_init_group(Group, Config, State) -> term() - - - - - - -pre_init_suite(Suite, Config, State) -> term() - - - - - - -pre_init_tc(TC, Config, State) -> term() - - - - - - -terminate(Config, State) -> term() - - - - - - - - -
\ No newline at end of file -- cgit v1.2.3 From a5c92f814fd5c59ec219b83f9af8826f5f046962 Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Mon, 14 Feb 2011 16:07:05 +0100 Subject: Fix bug with subgroups after introduction of remote groups --- lib/common_test/src/ct_framework.erl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/common_test') diff --git a/lib/common_test/src/ct_framework.erl b/lib/common_test/src/ct_framework.erl index 3050aec0c5..0d82a106d5 100644 --- a/lib/common_test/src/ct_framework.erl +++ b/lib/common_test/src/ct_framework.erl @@ -756,8 +756,9 @@ find(Mod, Name, TCs, [{Name,Props,Tests} | _Gs], Known, Defs, false) find(Mod, Name, TCs, [{Name1,Props,Tests} | Gs], Known, Defs, false) when is_atom(Name1), is_list(Props), is_list(Tests) -> cyclic_test(Mod, Name1, Known), - find(Mod, Name, TCs, Tests, [Name1 | Known], Defs, false) ++ - find(Mod, Name, TCs, Gs, [], Defs, false); + [make_conf(Mod,Name1,Props, + find(Mod, Name, TCs, Tests, [Name1 | Known], Defs, false)) | + find(Mod, Name, TCs, Gs, [], Defs, false)]; find(Mod, Name, _TCs, [{Name,_Props,_Tests} | _Gs], _Known, _Defs, true) when is_atom(Name) -> -- cgit v1.2.3