aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/src/ct_groups.erl
diff options
context:
space:
mode:
authorPeter Andersson <[email protected]>2012-11-19 18:01:04 +0100
committerPeter Andersson <[email protected]>2012-11-19 18:01:04 +0100
commit44fa71f32c0e901c73808657af7b8ab38158817b (patch)
tree33042d11f842887d826844da491145b32d63815d /lib/common_test/src/ct_groups.erl
parent0034dfc83ad3f18a67df38b4414fe74be7cbcdf6 (diff)
downloadotp-44fa71f32c0e901c73808657af7b8ab38158817b.tar.gz
otp-44fa71f32c0e901c73808657af7b8ab38158817b.tar.bz2
otp-44fa71f32c0e901c73808657af7b8ab38158817b.zip
Fix problem with test case order in group specifications
Diffstat (limited to 'lib/common_test/src/ct_groups.erl')
-rw-r--r--lib/common_test/src/ct_groups.erl80
1 files changed, 59 insertions, 21 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