diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/common_test/src/ct_groups.erl | 80 | ||||
-rw-r--r-- | lib/common_test/test/ct_groups_search_SUITE.erl | 52 |
2 files changed, 86 insertions, 46 deletions
diff --git a/lib/common_test/src/ct_groups.erl b/lib/common_test/src/ct_groups.erl index fc0f67d21d..24ca3826a8 100644 --- a/lib/common_test/src/ct_groups.erl +++ b/lib/common_test/src/ct_groups.erl @@ -287,31 +287,69 @@ rm_unwanted_tcs(Tests, all, []) -> Tests; rm_unwanted_tcs(Tests, TCs, []) -> - lists:flatmap(fun(Test) when is_tuple(Test), (size(Test) > 2) -> - [Test]; - (Test={group,_}) -> - [Test]; - (Test={_M,TC}) -> - case lists:member(TC, TCs) of - true -> [Test]; - false -> [] - end; - (Test) when is_atom(Test) -> - case lists:keysearch(Test, 2, TCs) of - {value,_} -> - [Test]; - _ -> - case lists:member(Test, TCs) of - true -> [Test]; - false -> [] - end - end; - (Test) -> [Test] - end, Tests); + sort_tests(lists:flatmap(fun(Test) when is_tuple(Test), + (size(Test) > 2) -> + [Test]; + (Test={group,_}) -> + [Test]; + (Test={_M,TC}) -> + case lists:member(TC, TCs) of + true -> [Test]; + false -> [] + end; + (Test) when is_atom(Test) -> + case lists:keysearch(Test, 2, TCs) of + {value,_} -> + [Test]; + _ -> + case lists:member(Test, TCs) of + true -> [Test]; + false -> [] + end + end; + (Test) -> [Test] + end, Tests), TCs); rm_unwanted_tcs(Tests, _TCs, _) -> [Test || Test <- Tests, not is_atom(Test)]. +%% make sure the order of tests is according to the order in TCs +sort_tests(Tests, TCs) when is_list(TCs)-> + lists:sort(fun(T1, T2) -> + case {is_tc(T1),is_tc(T2)} of + {true,true} -> + (position(T1, TCs) =< + position(T2, TCs)); + {false,true} -> + (position(T2, TCs) == (length(TCs)+1)); + _ -> true + + end + end, Tests); +sort_tests(Tests, _) -> + Tests. + +is_tc(T) when is_atom(T) -> true; +is_tc({group,_}) -> false; +is_tc({_M,T}) when is_atom(T) -> true; +is_tc(_) -> false. + +position(T, TCs) -> + position(T, TCs, 1). + +position(T, [T|_TCs], Pos) -> + Pos; +position(T, [{_,T}|_TCs], Pos) -> + Pos; +position({M,T}, [T|_TCs], Pos) when M /= group -> + Pos; +position(T, [_|TCs], Pos) -> + position(T, TCs, Pos+1); +position(_, [], Pos) -> + Pos. + +%%%----------------------------------------------------------------- + delete_subs([{conf, _,_,_,_} = Conf | Confs], All) -> All1 = delete_conf(Conf, All), case is_sub(Conf, All1) of diff --git a/lib/common_test/test/ct_groups_search_SUITE.erl b/lib/common_test/test/ct_groups_search_SUITE.erl index 76b2d14e5c..6b1c1f4634 100644 --- a/lib/common_test/test/ct_groups_search_SUITE.erl +++ b/lib/common_test/test/ct_groups_search_SUITE.erl @@ -162,7 +162,7 @@ all_groups(_) -> %%%----------------------------------------------------------------- %%% testcases_in_all_groups(_) -> - GPath = all, TCs = [sub_tc2,tc3], + GPath = all, TCs = [tc3,sub_tc2], Found = ct_groups:find_groups(?M2, GPath, TCs, groups2()), @@ -170,60 +170,61 @@ testcases_in_all_groups(_) -> {conf,[{name,top1}],{?M2,init_per_group}, [{?M2,tc3}, {conf,[{name,sub11}], - {?M2,init_per_group},[{?M2,sub_tc2},{?M2,tc3}], + {?M2,init_per_group},[{?M2,tc3},{?M2,sub_tc2}], {?M2,end_per_group}}, {conf,[{name,sub12}], {?M2,init_per_group}, - [{?M2,sub_tc2},{?M2,tc3}, + [{?M2,tc3},{?M2,sub_tc2}, {conf,[{name,sub121}], - {?M2,init_per_group},[{?M2,sub_tc2},{?M2,tc3}], + {?M2,init_per_group},[{?M2,tc3},{?M2,sub_tc2}], {?M2,end_per_group}}], {?M2,end_per_group}}], {?M2,end_per_group}}, Top2 = {conf,[{name,top2}],{?M2,init_per_group}, - [{conf,[{name,sub21}], + [{?M2,tc3}, + {conf,[{name,sub21}], {?M2,init_per_group}, - [{?M2,sub_tc2},{?M2,tc3}, + [{?M2,tc3},{?M2,sub_tc2}, {conf,[{name,sub2xx}], - {?M2,init_per_group},[{?M2,sub_tc2},{?M2,tc3}], + {?M2,init_per_group},[{?M2,tc3},{?M2,sub_tc2}], {?M2,end_per_group}}], {?M2,end_per_group}}, - {?M2,tc3}, % in top2 + {conf,[{name,sub22}], {?M2,init_per_group}, - [{conf,[{name,sub221}], - {?M2,init_per_group},[{?M2,sub_tc2},{?M2,tc3}], + [{?M2,tc3},{?M2,sub_tc2}, + {conf,[{name,sub221}], + {?M2,init_per_group},[{?M2,tc3},{?M2,sub_tc2}], {?M2,end_per_group}}, - {?M2,sub_tc2},{?M2,tc3}, % in sub22 {conf,[{name,sub2xx}], - {?M2,init_per_group},[{?M2,sub_tc2},{?M2,tc3}], + {?M2,init_per_group},[{?M2,tc3},{?M2,sub_tc2}], {?M2,end_per_group}}], {?M2,end_per_group}}], {?M2,end_per_group}}, {conf,[{name,sub21}], {?M2,init_per_group}, - [{?M2,sub_tc2},{?M2,tc3}, + [{?M2,tc3},{?M2,sub_tc2}, {conf,[{name,sub2xx}], - {?M2,init_per_group},[{?M2,sub_tc2},{?M2,tc3}],{?M2,end_per_group}}], + {?M2,init_per_group},[{?M2,tc3},{?M2,sub_tc2}],{?M2,end_per_group}}], {?M2,end_per_group}}, {conf,[{name,sub22}], {?M2,init_per_group}, - [{conf,[{name,sub221}], - {?M2,init_per_group},[{?M2,sub_tc2},{?M2,tc3}],{?M2,end_per_group}}, - {?M2,sub_tc2},{?M2,tc3}, + [{?M2,tc3},{?M2,sub_tc2}, + {conf,[{name,sub221}], + {?M2,init_per_group},[{?M2,tc3},{?M2,sub_tc2}],{?M2,end_per_group}}, {conf,[{name,sub2xx}], - {?M2,init_per_group},[{?M2,sub_tc2},{?M2,tc3}],{?M2,end_per_group}}], + {?M2,init_per_group},[{?M2,tc3},{?M2,sub_tc2}],{?M2,end_per_group}}], {?M2,end_per_group}}, {conf,[{name,sub221}], - {?M2,init_per_group},[{?M2,sub_tc2},{?M2,tc3}],{?M2,end_per_group}}, + {?M2,init_per_group},[{?M2,tc3},{?M2,sub_tc2}],{?M2,end_per_group}}, {conf,[{name,sub2xx}], - {?M2,init_per_group},[{?M2,sub_tc2},{?M2,tc3}],{?M2,end_per_group}}] + {?M2,init_per_group},[{?M2,tc3},{?M2,sub_tc2}],{?M2,end_per_group}}] = Found, @@ -450,7 +451,8 @@ testcase_in_top_groups2(_) -> {conf,[{name,top2}], {?M2,init_per_group}, - [{conf,[{name,sub21}], + [{?M2,tc3}, + {conf,[{name,sub21}], {?M2,init_per_group}, [{?M2,tc3}, {conf,[{name,sub2xx}], @@ -458,14 +460,14 @@ testcase_in_top_groups2(_) -> [{?M2,tc3}], {?M2,end_per_group}}], {?M2,end_per_group}}, - {?M2,tc3}, + {conf,[{name,sub22}], {?M2,init_per_group}, - [{conf,[{name,sub221}], + [{?M2,tc3}, + {conf,[{name,sub221}], {?M2,init_per_group}, [{?M2,tc3}], - {?M2,end_per_group}}, - {?M2,tc3}, + {?M2,end_per_group}}, {conf,[{name,sub2xx}], {?M2,init_per_group}, [{?M2,tc3}], |