Browse Source

Avoid reversing relx overlays.

This mostly moves a lists:reverse/1 which ensures that profile overlays
are run first but keeps the order of overlays otherwise.
pull/1563/head
Anthony Molinaro 8 years ago
parent
commit
249b5f13eb
2 changed files with 30 additions and 1 deletions
  1. +5
    -1
      src/rebar_relx.erl
  2. +25
    -0
      test/rebar_release_SUITE.erl

+ 5
- 1
src/rebar_relx.erl View File

@ -6,6 +6,10 @@
-export([do/4, -export([do/4,
format_error/1]). format_error/1]).
-ifdef(TEST).
-export([merge_overlays/1]).
-endif.
-include("rebar.hrl"). -include("rebar.hrl").
%% =================================================================== %% ===================================================================
@ -64,5 +68,5 @@ merge_overlays(Config) ->
(_) -> false (_) -> false
end, Config), end, Config),
%% Have profile overlay entries come before others to match how profiles work elsewhere %% Have profile overlay entries come before others to match how profiles work elsewhere
NewOverlay = lists:reverse(lists:flatmap(fun({overlay, Overlay}) -> Overlay end, Overlays)),
NewOverlay = lists:flatmap(fun({overlay, Overlay}) -> Overlay end, lists:reverse(Overlays)),
[{overlay, NewOverlay} | Others]. [{overlay, NewOverlay} | Others].

+ 25
- 0
test/rebar_release_SUITE.erl View File

@ -11,6 +11,7 @@ all() -> [release,
profile_ordering_sys_config_extend_3_tuple_merge, profile_ordering_sys_config_extend_3_tuple_merge,
extend_release, extend_release,
user_output_dir, profile_overlays, user_output_dir, profile_overlays,
profile_overlay_merge,
overlay_vars]. overlay_vars].
init_per_testcase(Case, Config0) -> init_per_testcase(Case, Config0) ->
@ -217,6 +218,30 @@ profile_overlays(Config) ->
{dir, filename:join(ReleaseDir, "randomdir")}]} {dir, filename:join(ReleaseDir, "randomdir")}]}
). ).
profile_overlay_merge (_Config) ->
% when profile and relx overlays both exist, the profile overlays should be
% first, then the relx overlays, all the rest of the config should come
% after, rebar_relx:merge_overlays/1 should do this.
RelxOverlay = [{mkdir, "1_from_relx"}, {mkdir, "2_from_relx"}],
ProfileOverlay = [{mkdir, "0_from_other_profile"}],
OtherConfig = [{other1, config}, {other2, config}],
% test with no overlays
?assertEqual([{overlay,[]}] ++ OtherConfig,
rebar_relx:merge_overlays(OtherConfig)),
% test with relx only, just move overlays to the top
RelxOnly = OtherConfig ++ [{overlay, RelxOverlay}],
?assertEqual([{overlay, RelxOverlay}]++OtherConfig,
rebar_relx:merge_overlays(RelxOnly)),
% now test with a profile (profiles end up after relx overlays
ProfilesToMerge = OtherConfig ++
[{overlay, RelxOverlay},
{overlay, ProfileOverlay}],
?assertEqual([{overlay, ProfileOverlay ++ RelxOverlay}] ++ OtherConfig,
rebar_relx:merge_overlays(ProfilesToMerge)).
overlay_vars(Config) -> overlay_vars(Config) ->
AppDir = ?config(apps, Config), AppDir = ?config(apps, Config),
Name = ?config(name, Config), Name = ?config(name, Config),

Loading…
Cancel
Save