diff options
author | Tristan Sloughter <t@crashfast.com> | 2015-12-06 13:48:20 -0600 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2015-12-06 13:48:20 -0600 |
commit | 540f2ebb0f8be681d342536ec5fb1f94ac392698 (patch) | |
tree | 414dd76da7517514947fa6dcfab436e0b6cafdeb | |
parent | 46181c8bf5863a828b87d0cf3f0aa4cf48f3f245 (diff) |
add tests for setting per-profile sys_config variables for relx
-rw-r--r-- | test/rebar_release_SUITE.erl | 69 |
1 files changed, 64 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), |