aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/rlx_config.erl26
-rw-r--r--test/rlx_release_SUITE.erl40
2 files changed, 45 insertions, 21 deletions
diff --git a/src/rlx_config.erl b/src/rlx_config.erl
index df08342..33e8f27 100644
--- a/src/rlx_config.erl
+++ b/src/rlx_config.erl
@@ -164,22 +164,9 @@ load_terms({lib_dirs, Dirs}, {ok, State}) ->
load_terms({hooks, Hooks}, {ok, State0}) ->
add_hooks(Hooks, State0);
load_terms({providers, Providers0}, {ok, State0}) ->
- Providers1 = gen_providers(Providers0, State0),
- case Providers1 of
- {_, E={error, _}} ->
- E;
- {Providers3, {ok, State3}} ->
- {ok, rlx_state:providers(State3, Providers3)}
- end;
+ gen_providers(Providers0, State0);
load_terms({add_providers, Providers0}, {ok, State0}) ->
- Providers1 = gen_providers(Providers0, State0),
- case Providers1 of
- {_, E={error, _}} ->
- E;
- {Providers3, {ok, State1}} ->
- ExistingProviders = rlx_state:providers(State1),
- {ok, rlx_state:providers(State1, ExistingProviders ++ Providers3)}
- end;
+ gen_providers(Providers0, State0);
load_terms({skip_apps, SkipApps0}, {ok, State0}) ->
{ok, rlx_state:skip_apps(State0, SkipApps0)};
load_terms({exclude_apps, ExcludeApps0}, {ok, State0}) ->
@@ -260,14 +247,13 @@ load_terms(InvalidTerm, _) ->
?RLX_ERROR({invalid_term, InvalidTerm}).
-spec gen_providers([module()], rlx_state:t()) ->
- {[providers:t()], {ok, rlx_state:t()} | relx:error()}.
+ {ok, rlx_state:t()} | relx:error().
gen_providers(Providers, State) ->
- lists:foldl(fun(ProviderName, {Providers1, {ok, State1}}) ->
- {Provider, State2} = providers:new(ProviderName, State1),
- {[Provider | Providers1], State2};
+ lists:foldl(fun(ProviderName, {ok, State1}) ->
+ providers:new(ProviderName, State1);
(_, E={_, {error, _}}) ->
E
- end, {[], {ok, State}}, Providers).
+ end, {ok, State}, Providers).
add_hooks(Hooks, State) ->
{ok, lists:foldl(fun({pre, Target, Hook}, StateAcc) ->
diff --git a/test/rlx_release_SUITE.erl b/test/rlx_release_SUITE.erl
index c4c782b..9b09ab9 100644
--- a/test/rlx_release_SUITE.erl
+++ b/test/rlx_release_SUITE.erl
@@ -24,6 +24,7 @@
end_per_suite/1,
init_per_testcase/2,
all/0,
+ add_providers/1,
make_release/1,
make_extend_release/1,
make_scriptless_release/1,
@@ -67,7 +68,7 @@ init_per_testcase(_, Config) ->
{state, State1} | Config].
all() ->
- [make_release, make_extend_release, make_scriptless_release,
+ [add_providers, make_release, make_extend_release, make_scriptless_release,
make_overridden_release, make_auto_skip_empty_app_release,
make_skip_app_release, make_exclude_app_release, make_app_type_none_release,
make_implicit_config_release, make_rerun_overridden_release,
@@ -76,6 +77,43 @@ all() ->
make_one_app_top_level_release, make_dev_mode_release,
make_config_script_release].
+add_providers(Config) ->
+ LibDir1 = proplists:get_value(lib1, Config),
+
+ [(fun({Name, Vsn}) ->
+ rlx_test_utils:create_app(LibDir1, Name, Vsn, [kernel, stdlib], [])
+ end)(App)
+ ||
+ App <-
+ [{rlx_test_utils:create_random_name("lib_app1_"), rlx_test_utils:create_random_vsn()}
+ || _ <- lists:seq(1, 100)]],
+
+ rlx_test_utils:create_app(LibDir1, "goal_app_1", "0.0.1", [stdlib,kernel,non_goal_1], []),
+ rlx_test_utils:create_app(LibDir1, "lib_dep_1", "0.0.1", [stdlib,kernel], []),
+ rlx_test_utils:create_app(LibDir1, "goal_app_2", "0.0.1", [stdlib,kernel,goal_app_1,non_goal_2], []),
+ rlx_test_utils:create_app(LibDir1, "non_goal_1", "0.0.1", [stdlib,kernel], [lib_dep_1]),
+ rlx_test_utils:create_app(LibDir1, "non_goal_2", "0.0.1", [stdlib,kernel], []),
+
+ ConfigFile = filename:join([LibDir1, "relx.config"]),
+ rlx_test_utils:write_config(ConfigFile,
+ [{release, {foo, "0.0.1"},
+ [goal_app_1,
+ goal_app_2]},
+ {add_providers, [rlx_prv_app_discover]}]),
+ OutputDir = filename:join([proplists:get_value(data_dir, Config),
+ rlx_test_utils:create_random_name("relx-output")]),
+ {ok, State} = relx:do(undefined, undefined, [], [LibDir1], 3,
+ OutputDir, ConfigFile),
+ [{{foo, "0.0.1"}, Release}] = ec_dictionary:to_list(rlx_state:realized_releases(State)),
+ AppSpecs = rlx_release:applications(Release),
+ ?assert(lists:keymember(stdlib, 1, AppSpecs)),
+ ?assert(lists:keymember(kernel, 1, AppSpecs)),
+ ?assert(lists:member({non_goal_1, "0.0.1"}, AppSpecs)),
+ ?assert(lists:member({non_goal_2, "0.0.1"}, AppSpecs)),
+ ?assert(lists:member({goal_app_1, "0.0.1"}, AppSpecs)),
+ ?assert(lists:member({goal_app_2, "0.0.1"}, AppSpecs)),
+ ?assert(lists:member({lib_dep_1, "0.0.1", load}, AppSpecs)).
+
make_release(Config) ->
LibDir1 = proplists:get_value(lib1, Config),