diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/rebar_profiles_SUITE.erl | 54 | ||||
-rw-r--r-- | test/rebar_utils_SUITE.erl | 23 |
2 files changed, 55 insertions, 22 deletions
diff --git a/test/rebar_profiles_SUITE.erl b/test/rebar_profiles_SUITE.erl index d1d10c6..f812793 100644 --- a/test/rebar_profiles_SUITE.erl +++ b/test/rebar_profiles_SUITE.erl @@ -11,6 +11,7 @@ implicit_profile_deduplicate_deps/1, profile_merges/1, same_profile_deduplication/1, + stack_deduplication/1, add_to_profile/1, add_to_existing_profile/1, profiles_remain_applied_with_config_present/1, @@ -26,7 +27,7 @@ all() -> [profile_new_key, profile_merge_keys, profile_merges, explicit_profile_deduplicate_deps, implicit_profile_deduplicate_deps, - same_profile_deduplication, + same_profile_deduplication, stack_deduplication, add_to_profile, add_to_existing_profile, profiles_remain_applied_with_config_present, test_profile_applied_at_completion, @@ -199,7 +200,7 @@ same_profile_deduplication(_Config) -> {test3, [key3]}, {profiles, [{profile1, - [{test1, [{key3, 5}, key1]}, + [{test1, [{key3, 5}, {key2, "hello"}]}, {test2, [bar]}, {test3, []} ]}] @@ -208,15 +209,56 @@ same_profile_deduplication(_Config) -> State1 = rebar_state:apply_profiles(State, [profile1, profile1, profile1]), ?assertEqual([default, profile1], rebar_state:current_profiles(State1)), + Test1 = rebar_state:get(State1, test1), + %% Combine lists - ?assertEqual(lists:sort([key1, key2, {key1, 1, 2}, {key3, 5}]), - lists:sort(rebar_state:get(State1, test1))), + ?assertEqual(lists:sort([key2, {key1, 1, 2}, {key3, 5}, {key2, "hello"}]), + lists:sort(Test1)), + %% Key2 from profile1 overrides key2 from default profile + ?assertEqual("hello", proplists:get_value(key2, Test1)), %% Check that a newvalue of []/"" doesn't override non-string oldvalues ?assertEqual([key3], rebar_state:get(State1, test3)), - ?assertEqual([foo, bar], rebar_state:get(State1, test2)). - + ?assertEqual([bar, foo], rebar_state:get(State1, test2)). + +stack_deduplication(_Config) -> + RebarConfig = [ + {test_key, default}, + {test_list, [ {foo, default} ]}, + {profiles, [ + {a, [ + {test_key, a}, + {test_list, [ {foo, a} ]} + ]}, + {b, [ + {test_key, b}, + {test_list, [ {foo, b} ]} + ]}, + {c, [ + {test_key, c}, + {test_list, [ {foo, c} ]} + ]}, + {d, [ + {test_key, d}, + {test_list, [ {foo, d} ]} + ]}, + {e, [ + {test_key, e}, + {test_list, [ {foo, e} ]} + ]} + ]} + ], + State = rebar_state:new(RebarConfig), + State1 = rebar_state:apply_profiles(State, [a, b, c, d, e, a, e, b]), + ?assertEqual(b, rebar_state:get(State1, test_key)), + + TestList = rebar_state:get(State1, test_list), + ?assertEqual( + [{foo, b}, {foo, e}, {foo, a}, {foo, d}, {foo, c}, {foo, default} ], + TestList + ), + ?assertEqual(b, proplists:get_value(foo, TestList)). add_to_profile(_Config) -> RebarConfig = [{foo, true}, {bar, false}], diff --git a/test/rebar_utils_SUITE.erl b/test/rebar_utils_SUITE.erl index 9b7bca1..98e7e58 100644 --- a/test/rebar_utils_SUITE.erl +++ b/test/rebar_utils_SUITE.erl @@ -22,8 +22,7 @@ task_with_flag_with_commas/1, task_with_multiple_flags/1, special_task_do/1, - trivial_umerge/1, - three_tuple_umerge/1]). + tup_umerge_deduplication/1]). -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). @@ -32,8 +31,7 @@ all() -> [{group, args_to_tasks}, - trivial_umerge, - three_tuple_umerge + tup_umerge_deduplication ]. groups() -> @@ -124,17 +122,10 @@ special_task_do(_Config) -> "bar,", "baz"]). -trivial_umerge(_Config) -> - New = [{key, foo}], - Old = [{key, bar}], - Result = rebar_utils:tup_umerge(New, Old), - ?assertEqual([{key, foo}], Result). - -three_tuple_umerge(_Config) -> - New = rebar_utils:tup_sort([{d, foo, true}, {d, bar, true}]), - Old = rebar_utils:tup_sort([{d, foo, false}, {d, bar, true}]), - Result = rebar_utils:tup_umerge(New, Old), +tup_umerge_deduplication(_Config) -> + Old = [{key,c},{key,b},{key,a}], + New = [{key, a}], ?assertEqual( - rebar_utils:tup_sort([{do, foo, true}, {d, bar, true}]), - Result + [{key, a}, {key, c}, {key, b}], + rebar_utils:tup_umerge(New, Old) ). |