diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2017-09-01 16:39:02 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-01 16:39:02 -0400 |
commit | 46a082afec58d8081a3a896a7f64b9cbfb71a19c (patch) | |
tree | a6ddee89a1c8b41903123d79d8cb3d11644eaf57 | |
parent | 03f6f634f03de894c2322e9df3b2b3b36d102a4f (diff) | |
parent | 8e4f90fa08bb44e041b4225c49d5a75124adcb3c (diff) |
Merge pull request #1625 from tsloughter/ct-sys-config-merging
fix sys config merging
-rw-r--r-- | src/rebar_file_utils.erl | 5 | ||||
-rw-r--r-- | test/rebar_ct_SUITE.erl | 12 |
2 files changed, 14 insertions, 3 deletions
diff --git a/src/rebar_file_utils.erl b/src/rebar_file_utils.erl index c860513..4a783f2 100644 --- a/src/rebar_file_utils.erl +++ b/src/rebar_file_utils.erl @@ -75,8 +75,9 @@ consult_config(State, Filename) -> JoinedConfig = lists:flatmap( fun (SubConfig) when is_list(SubConfig) -> case lists:suffix(".config", SubConfig) of - false -> consult_config(State, SubConfig ++ ".config"); - true -> consult_config(State, SubConfig) + %% since consult_config returns a list in a list we take the head here + false -> hd(consult_config(State, SubConfig ++ ".config")); + true -> hd(consult_config(State, SubConfig)) end; (Entry) -> [Entry] end, Config), diff --git a/test/rebar_ct_SUITE.erl b/test/rebar_ct_SUITE.erl index 70cf60c..f009930 100644 --- a/test/rebar_ct_SUITE.erl +++ b/test/rebar_ct_SUITE.erl @@ -1132,12 +1132,19 @@ cmd_sys_config(Config) -> CfgFile = filename:join([AppDir, "config", "cfg_sys.config"]), ok = filelib:ensure_dir(CfgFile), ok = file:write_file(CfgFile, cfg_sys_config_file(AppName)), + + OtherCfgFile = filename:join([AppDir, "config", "other.config"]), + ok = filelib:ensure_dir(OtherCfgFile), + ok = file:write_file(OtherCfgFile, other_sys_config_file(AppName)), + RebarConfig = [{ct_opts, [{sys_config, CfgFile}]}], {ok, State1} = rebar_test_utils:run_and_check(Config, RebarConfig, ["as", "test", "lock"], return), {ok, _} = rebar_prv_common_test:prepare_tests(State1), ?assertEqual({ok, cfg_value}, application:get_env(AppName, key)), + ?assertEqual({ok, other_cfg_value}, application:get_env(AppName, other_key)), + Providers = rebar_state:providers(State1), Namespace = rebar_state:namespace(State1), CommandProvider = providers:get_provider(ct, Providers, Namespace), @@ -1614,4 +1621,7 @@ cmd_sys_config_file(AppName) -> io_lib:format("[{~ts, [{key, cmd_value}]}].", [AppName]). cfg_sys_config_file(AppName) -> - io_lib:format("[{~ts, [{key, cfg_value}]}].", [AppName]). + io_lib:format("[{~ts, [{key, cfg_value}]}, \"config/other\"].", [AppName]). + +other_sys_config_file(AppName) -> + io_lib:format("[{~ts, [{other_key, other_cfg_value}]}].", [AppName]). |