Skip to content

Commit

Permalink
Merge pull request #79 from tsloughter/master
Browse files Browse the repository at this point in the history
add extend to release definition. This closes #16
  • Loading branch information
jwilberding committed Oct 19, 2013
2 parents e149dfd + a19a0cd commit 794242f
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/rlx_prv_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ load_terms({dev_mode, DevMode}, {ok, State0}) ->
{ok, rlx_state:dev_mode(State0, DevMode)};
load_terms({include_src, IncludeSrc}, {ok, State0}) ->
{ok, rlx_state:include_src(State0, IncludeSrc)};
load_terms({release, {RelName, Vsn, {extend, RelName2}}, Applications}, {ok, State0}) ->
Release0 = rlx_release:new(RelName, Vsn),
ExtendRelease = rlx_state:get_configured_release(State0, RelName2, Vsn),
Applications1 = rlx_release:goals(ExtendRelease),
case rlx_release:goals(Release0,
lists:umerge(lists:usort(Applications),
lists:usort(Applications1))) of
E={error, _} ->
E;
{ok, Release1} ->
{ok, rlx_state:add_configured_release(State0, Release1)}
end;
load_terms({release, {RelName, Vsn}, Applications}, {ok, State0}) ->
Release0 = rlx_release:new(RelName, Vsn),
case rlx_release:goals(Release0, Applications) of
Expand Down
42 changes: 40 additions & 2 deletions test/rlx_release_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
init_per_testcase/2,
all/0,
make_release/1,
make_extend_release/1,
make_scriptless_release/1,
make_overridden_release/1,
make_skip_app_release/1,
Expand Down Expand Up @@ -64,8 +65,8 @@ init_per_testcase(_, Config) ->
{state, State} | Config].

all() ->
[make_release, make_scriptless_release, make_overridden_release,
make_auto_skip_empty_app_release,
[make_release, make_extend_release, make_scriptless_release,
make_overridden_release, make_auto_skip_empty_app_release,
make_skip_app_release, make_app_type_none_release,
make_implicit_config_release, make_rerun_overridden_release,
overlay_release, make_goalless_release, make_depfree_release,
Expand Down Expand Up @@ -107,6 +108,43 @@ make_release(Config) ->
?assert(lists:member({goal_app_2, "0.0.1"}, AppSpecs)),
?assert(lists:member({lib_dep_1, "0.0.1", load}, AppSpecs)).

make_extend_release(Config) ->
LibDir1 = proplists:get_value(lib1, Config),
[(fun({Name, Vsn}) ->
create_app(LibDir1, Name, Vsn, [kernel, stdlib], [])
end)(App)
||
App <-
[{create_random_name("lib_app1_"), create_random_vsn()}
|| _ <- lists:seq(1, 100)]],

create_app(LibDir1, "goal_app_1", "0.0.1", [stdlib,kernel,non_goal_1], []),
create_app(LibDir1, "lib_dep_1", "0.0.1", [stdlib,kernel], []),
create_app(LibDir1, "goal_app_2", "0.0.1", [stdlib,kernel,goal_app_1,non_goal_2], []),
create_app(LibDir1, "non_goal_1", "0.0.1", [stdlib,kernel], [lib_dep_1]),
create_app(LibDir1, "non_goal_2", "0.0.1", [stdlib,kernel], []),

ConfigFile = filename:join([LibDir1, "relx.config"]),
write_config(ConfigFile,
[{release, {foo, "0.0.1"},
[goal_app_1,
goal_app_2]},
{release, {foo_test, "0.0.1", {extend, foo}},
[goal_app_2]}]),
OutputDir = filename:join([proplists:get_value(data_dir, Config),
create_random_name("relx-output")]),
{ok, State} = relx:do(foo_test, undefined, [], [LibDir1], 3,
OutputDir, ConfigFile),
[{{foo_test, "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_invalid_config_release(Config) ->
LibDir1 = proplists:get_value(lib1, Config),
[(fun({Name, Vsn}) ->
Expand Down

0 comments on commit 794242f

Please sign in to comment.