Pārlūkot izejas kodu

Merge pull request #1348 from ElectronicRU/master

Fix sys.config's handling in common_test and otherwise.

closes #1289
pull/1353/head
alisdair sullivan pirms 8 gadiem
revīziju iesūtīja GitHub
vecāks
revīzija
24a43accbd
3 mainītis faili ar 24 papildinājumiem un 6 dzēšanām
  1. +10
    -5
      src/rebar_file_utils.erl
  2. +5
    -0
      src/rebar_prv_common_test.erl
  3. +9
    -1
      src/rebar_utils.erl

+ 10
- 5
src/rebar_file_utils.erl Parādīt failu

@ -72,11 +72,16 @@ consult_config(State, Filename) ->
[T] -> T;
[] -> []
end,
SubConfigs = [consult_config(State, Entry ++ ".config") ||
Entry <- Config, is_list(Entry)
],
[Config | lists:merge(SubConfigs)].
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)
end;
(Entry) -> [Entry]
end, Config),
%% Backwards compatibility
[JoinedConfig].
format_error({bad_term_file, AppFile, Reason}) ->
io_lib:format("Error reading file ~s: ~s", [AppFile, file:format_error(Reason)]).

+ 5
- 0
src/rebar_prv_common_test.erl Parādīt failu

@ -221,8 +221,13 @@ select_tests(State, ProjectApps, CmdOpts, CfgOpts) ->
Configs = lists:flatmap(fun(Filename) ->
rebar_file_utils:consult_config(State, Filename)
end, SysConfigs),
%% NB: load the applications (from user directories too) to support OTP < 17
%% to our best ability.
OldPath = code:get_path(),
code:add_pathsa(rebar_state:code_paths(State, all_deps)),
[application:load(Application) || Config <- Configs, {Application, _} <- Config],
rebar_utils:reread_config(Configs),
code:set_path(OldPath),
Merged = lists:ukeymerge(1,
lists:ukeysort(1, CmdOpts),

+ 9
- 1
src/rebar_utils.erl Parādīt failu

@ -414,8 +414,16 @@ user_agent() ->
?FMT("Rebar/~s (OTP/~s)", [Vsn, otp_release()]).
reread_config(ConfigList) ->
%% NB: we attempt to mimic -config here, which survives app reload,
%% hence {persistent, true}.
SetEnv = case version_tuple(?MODULE:otp_release()) of
{X, _, _} when X =< 17 ->
fun application:set_env/3;
_ ->
fun (App, Key, Val) -> application:set_env(App, Key, Val, [{persistent, true}]) end
end,
try
[application:set_env(Application, Key, Val)
[SetEnv(Application, Key, Val)
|| Config <- ConfigList,
{Application, Items} <- Config,
{Key, Val} <- Items]

Notiek ielāde…
Atcelt
Saglabāt