diff options
author | Tristan Sloughter <tristan.sloughter@gmail.com> | 2015-02-24 19:15:16 -0600 |
---|---|---|
committer | Tristan Sloughter <tristan.sloughter@gmail.com> | 2015-02-24 19:15:16 -0600 |
commit | ba2e2cb32811358c200d144d95209972487529b7 (patch) | |
tree | 36599dea2e020098b21b26937ad603552f57d1a2 | |
parent | ef83d4e82153bb4142c116286d1f96ffeff8676a (diff) | |
parent | 235436a41090e45397e97c33cf0ef9d3413fc23c (diff) |
Merge pull request #182 from tsloughter/profile_tests
profiles: combine lists of values for conflicting config options
-rw-r--r-- | src/rebar_state.erl | 4 | ||||
-rw-r--r-- | test/rebar_profiles_SUITE.erl | 22 | ||||
-rw-r--r-- | test/rebar_xref_SUITE.erl | 2 |
3 files changed, 22 insertions, 6 deletions
diff --git a/src/rebar_state.erl b/src/rebar_state.erl index 70aba51..09f1c43 100644 --- a/src/rebar_state.erl +++ b/src/rebar_state.erl @@ -207,9 +207,7 @@ merge_opts(Profile, NewOpts, OldOpts) -> true -> NewValue; false -> - lists:keymerge(1 - ,lists:keysort(1, OldValue) - ,lists:keysort(1, NewValue)) + OldValue ++ NewValue end; (_Key, NewValue, _OldValue) -> NewValue diff --git a/test/rebar_profiles_SUITE.erl b/test/rebar_profiles_SUITE.erl index 802b772..0b378cb 100644 --- a/test/rebar_profiles_SUITE.erl +++ b/test/rebar_profiles_SUITE.erl @@ -6,14 +6,15 @@ end_per_testcase/2, all/0, profile_new_key/1, - profile_merge_keys/1]). + profile_merge_keys/1, + profile_merges/1]). -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). -include_lib("kernel/include/file.hrl"). all() -> - [profile_new_key, profile_merge_keys]. + [profile_new_key, profile_merge_keys, profile_merges]. init_per_suite(Config) -> application:start(meck), @@ -80,3 +81,20 @@ profile_merge_keys(Config) -> ["as", "ct", "compile"], {ok, [{app, Name} ,{dep, "a", "1.0.0"} ,{dep, "b", "2.0.0"}]}). + +profile_merges(_Config) -> + RebarConfig = [{test1, [{key1, 1, 2}, key2]}, + {test2, "hello"}, + {profiles, + [{profile1, + [{test1, [{key3, 5}, key1]}]}, + {profile2, [{test2, "goodbye"}]}]}], + State = rebar_state:new(RebarConfig), + State1 = rebar_state:apply_profiles(State, [profile1, profile2]), + + %% Combine lists + ?assertEqual(lists:sort([key1, key2, {key1, 1, 2}, {key3, 5}]), + lists:sort(rebar_state:get(State1, test1))), + + %% Use new value for strings + "goodbye" = rebar_state:get(State1, test2). diff --git a/test/rebar_xref_SUITE.erl b/test/rebar_xref_SUITE.erl index fde8c8f..067be07 100644 --- a/test/rebar_xref_SUITE.erl +++ b/test/rebar_xref_SUITE.erl @@ -57,7 +57,7 @@ end_per_testcase(_, Config) -> %% we are about to remove the directory and there may be %% subsequent test cases that error out when the code path tries %% to include one of these soon-to-be nonexistent directories. - true = code:del_path(AppDir ++ "/."), + code:del_path(AppDir ++ "/."), true = code:del_path(rebar_dir:ebin_dir()), file:set_cwd(OrigDir), ec_file:remove(AppDir, [recursive]), |