diff options
author | Eric <[email protected]> | 2012-12-31 15:19:18 -0500 |
---|---|---|
committer | Eric <[email protected]> | 2012-12-31 15:19:18 -0500 |
commit | a0bd0b37822999f87786d670529624594c82b0a8 (patch) | |
tree | 91cc6038677562d873fae1f212c4aeb6e2aad6f2 | |
parent | 059d9f6d28d8f4e963f556401e23eed44fc44b9d (diff) | |
download | relx-a0bd0b37822999f87786d670529624594c82b0a8.tar.gz relx-a0bd0b37822999f87786d670529624594c82b0a8.tar.bz2 relx-a0bd0b37822999f87786d670529624594c82b0a8.zip |
fix bug in goalless configs
-rw-r--r-- | src/rcl_prv_release.erl | 17 | ||||
-rw-r--r-- | test/rclt_release_SUITE.erl | 33 |
2 files changed, 42 insertions, 8 deletions
diff --git a/src/rcl_prv_release.erl b/src/rcl_prv_release.erl index 66f4e11..8a86e02 100644 --- a/src/rcl_prv_release.erl +++ b/src/rcl_prv_release.erl @@ -47,6 +47,8 @@ do(State) -> find_default_release(State, DepGraph). -spec format_error(ErrorDetail::term()) -> iolist(). +format_error(no_goals_specified) -> + "No goals specified for this release ~n"; format_error({no_release_name, Vsn}) -> io_lib:format("A target release version was specified (~s) but no name", [Vsn]); format_error({invalid_release_info, Info}) -> @@ -151,11 +153,16 @@ solve_release(State0, DepGraph, RelName, RelVsn) -> try Release = rcl_state:get_release(State0, RelName, RelVsn), Goals = rcl_release:goals(Release), - case rcl_depsolver:solve(DepGraph, Goals) of - {ok, Pkgs} -> - set_resolved(State0, Release, Pkgs); - {error, Error} -> - ?RCL_ERROR({failed_solve, Error}) + case Goals of + [] -> + ?RCL_ERROR(no_goals_specified); + _ -> + case rcl_depsolver:solve(DepGraph, Goals) of + {ok, Pkgs} -> + set_resolved(State0, Release, Pkgs); + {error, Error} -> + ?RCL_ERROR({failed_solve, Error}) + end end catch throw:not_found -> diff --git a/test/rclt_release_SUITE.erl b/test/rclt_release_SUITE.erl index e92772e..baf2fcd 100644 --- a/test/rclt_release_SUITE.erl +++ b/test/rclt_release_SUITE.erl @@ -29,7 +29,8 @@ make_overridden_release/1, make_rerun_overridden_release/1, make_implicit_config_release/1, - overlay_release/1]). + overlay_release/1, + make_goalless_release/1]). -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). @@ -56,7 +57,7 @@ init_per_testcase(_, Config) -> all() -> [make_release, make_scriptless_release, make_overridden_release, make_implicit_config_release, make_rerun_overridden_release, - overlay_release]. + overlay_release, make_goalless_release]. make_release(Config) -> LibDir1 = proplists:get_value(lib1, Config), @@ -262,7 +263,7 @@ make_rerun_overridden_release(Config) -> [ConfigFile]), %% Now we run it again to see if it failse. - {ok, State} = relcool:do(Cwd, undefined, undefined, [], [LibDir1], 2, + {ok, State} = relcool:do(Cwd,undefined, undefined, [], [LibDir1], 2, OutputDir, [{OverrideAppName, OverrideAppDir}], [ConfigFile]), @@ -414,6 +415,32 @@ overlay_release(Config) -> ?assertEqual("yahoo/bar", proplists:get_value(yahoo3, TemplateData)). +make_goalless_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", [], []), + 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, "relcool.config"]), + write_config(ConfigFile, + [{release, {foo, "0.0.1"}, + []}]), + OutputDir = filename:join([proplists:get_value(data_dir, Config), + create_random_name("relcool-output")]), + ?assertMatch({error,{rcl_prv_release,no_goals_specified}}, + relcool:do(undefined, undefined, [], [LibDir1], 2, + OutputDir, [ConfigFile])). + %%%=================================================================== %%% Helper Functions %%%=================================================================== |