diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/rebar_release_SUITE.erl | 69 | ||||
-rw-r--r-- | test/rebar_utils_SUITE.erl | 7 |
2 files changed, 71 insertions, 5 deletions
diff --git a/test/rebar_release_SUITE.erl b/test/rebar_release_SUITE.erl index f6fe8ff..e0fa5a0 100644 --- a/test/rebar_release_SUITE.erl +++ b/test/rebar_release_SUITE.erl @@ -4,11 +4,13 @@ -include_lib("eunit/include/eunit.hrl"). all() -> [release, - dev_mode_release, - profile_dev_mode_override_release, - tar, - extend_release, - user_output_dir]. + dev_mode_release, + profile_dev_mode_override_release, + tar, + profile_ordering_sys_config_extend, + profile_ordering_sys_config_extend_3_tuple_merge, + extend_release, + user_output_dir]. init_per_testcase(Case, Config0) -> Config = rebar_test_utils:init_rebar_state(Config0), @@ -111,6 +113,63 @@ extend_release(Config) -> {ok, [{release, extended, Vsn, false}]} ). +%% Ensure proper ordering of sys_config and extended releases in profiles +profile_ordering_sys_config_extend(Config) -> + AppDir = ?config(apps, Config), + Name = ?config(name, Config), + Vsn = "1.0.0", + TestSysConfig = filename:join(AppDir, "test.config"), + OtherSysConfig = filename:join(AppDir, "other.config"), + ok = file:write_file(TestSysConfig, "[]."), + ok = file:write_file(OtherSysConfig, "[{some, content}]."), + {ok, RebarConfig} = + file:consult(rebar_test_utils:create_config(AppDir, + [{relx, [{release, {list_to_atom(Name), Vsn}, + [list_to_atom(Name)]}, + {sys_config, OtherSysConfig}, + {lib_dirs, [AppDir]}]}, + {profiles, [{extended, + [{relx, [ + {sys_config, TestSysConfig}]}]}]}])), + rebar_test_utils:run_and_check( + Config, RebarConfig, + ["as", "extended", "release"], + {ok, [{release, list_to_atom(Name), Vsn, false}]} + ), + + ReleaseDir = filename:join([AppDir, "./_build/extended/rel/", Name, "releases", Vsn]), + {ok, [[]]} = file:consult(filename:join(ReleaseDir, "sys.config")). + +%% test that tup_umerge works with tuples of different sizes +profile_ordering_sys_config_extend_3_tuple_merge(Config) -> + AppDir = ?config(apps, Config), + Name = ?config(name, Config), + Vsn = "1.0.0", + TestSysConfig = filename:join(AppDir, "test.config"), + OtherSysConfig = filename:join(AppDir, "other.config"), + ok = file:write_file(TestSysConfig, "[]."), + ok = file:write_file(OtherSysConfig, "[{some, content}]."), + {ok, RebarConfig} = + file:consult(rebar_test_utils:create_config(AppDir, + [{relx, [{release, {list_to_atom(Name), Vsn}, + [list_to_atom(Name)]}, + {sys_config, OtherSysConfig}, + {lib_dirs, [AppDir]}]}, + {profiles, [{extended, + [{relx, [ + {release, {extended, Vsn, {extend, list_to_atom(Name)}}, + []}, + {sys_config, TestSysConfig}]}]}]}])), + + rebar_test_utils:run_and_check( + Config, RebarConfig, + ["as", "extended", "release", "-n", Name], + {ok, [{release, list_to_atom(Name), Vsn, false}]} + ), + + ReleaseDir = filename:join([AppDir, "./_build/extended/rel/", Name, "releases", Vsn]), + {ok, [[]]} = file:consult(filename:join(ReleaseDir, "sys.config")). + user_output_dir(Config) -> AppDir = ?config(apps, Config), Name = ?config(name, Config), diff --git a/test/rebar_utils_SUITE.erl b/test/rebar_utils_SUITE.erl index 42a9551..b32992d 100644 --- a/test/rebar_utils_SUITE.erl +++ b/test/rebar_utils_SUITE.erl @@ -259,6 +259,13 @@ tup_merge(_Config) -> ) ), ?assertEqual( + [{l, a}, {r, a, b}, {s, a}, {s, b}], + rebar_utils:tup_umerge( + rebar_utils:tup_sort([{r, a, b}, {s, a}, {l, a}]), + rebar_utils:tup_sort([{s, b}]) + ) + ), + ?assertEqual( [{a,b,b},{a,b},a,{a,a},{a,a,a},{b,b},{b,b,b},b,{b,a,a},{b,a},{z,b},{z,b,b},z,{z,a},{z,a,a}], rebar_utils:tup_umerge( rebar_utils:tup_sort([{a,b,b},{b,b},{a,b},{b,b,b},{z,b},{z,b,b},a,b,z]), |