Bladeren bron

profiles: combine lists of values for conflicting config options

pull/182/head
Tristan Sloughter 10 jaren geleden
bovenliggende
commit
235436a410
3 gewijzigde bestanden met toevoegingen van 22 en 6 verwijderingen
  1. +1
    -3
      src/rebar_state.erl
  2. +20
    -2
      test/rebar_profiles_SUITE.erl
  3. +1
    -1
      test/rebar_xref_SUITE.erl

+ 1
- 3
src/rebar_state.erl Bestand weergeven

@ -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

+ 20
- 2
test/rebar_profiles_SUITE.erl Bestand weergeven

@ -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).

+ 1
- 1
test/rebar_xref_SUITE.erl Bestand weergeven

@ -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]),

Laden…
Annuleren
Opslaan