diff options
author | Tristan Sloughter <[email protected]> | 2016-10-06 14:00:43 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2016-10-06 14:00:43 -0700 |
commit | be045b566fbbf63b0074dc970dd4e65d8f644302 (patch) | |
tree | 5f26b4f4f2e4287863360abdb9728cb66de5bd17 | |
parent | 2ba3b82801ade6ee803c1831a629d0a099df7a7c (diff) | |
parent | 3a2003e5683aaeaab69a403abba47df4b0b891c2 (diff) | |
download | relx-be045b566fbbf63b0074dc970dd4e65d8f644302.tar.gz relx-be045b566fbbf63b0074dc970dd4e65d8f644302.tar.bz2 relx-be045b566fbbf63b0074dc970dd4e65d8f644302.zip |
Merge pull request #515 from lrascao/feature/erts_include_src
Don't include erts src when user requests src not be included
-rw-r--r-- | src/rlx_prv_assembler.erl | 8 | ||||
-rw-r--r-- | test/rlx_release_SUITE.erl | 65 | ||||
-rw-r--r-- | test/rlx_test_utils.erl | 6 |
3 files changed, 77 insertions, 2 deletions
diff --git a/src/rlx_prv_assembler.erl b/src/rlx_prv_assembler.erl index 53b7dfa..1f64886 100644 --- a/src/rlx_prv_assembler.erl +++ b/src/rlx_prv_assembler.erl @@ -502,6 +502,14 @@ include_erts(State, Release, OutputDir, RelDir) -> ok = file:write_file(ErlIni, erl_ini(OutputDir, ErtsVersion)) end, + %% delete erts src if the user requested it not be included + case rlx_state:include_src(State) of + true -> ok; + false -> + SrcDir = filename:join([LocalErts, "src"]), + ok = ec_file:remove(SrcDir, [recursive]) + end, + case rlx_state:get(State, extended_start_script, false) of true -> diff --git a/test/rlx_release_SUITE.erl b/test/rlx_release_SUITE.erl index 2b30923..0ee9124 100644 --- a/test/rlx_release_SUITE.erl +++ b/test/rlx_release_SUITE.erl @@ -51,7 +51,9 @@ make_release_twice_dev_mode/1, make_erts_release/1, make_erts_config_release/1, - make_included_nodetool_release/1]). + make_included_nodetool_release/1, + make_src_release/1, + make_excluded_src_release/1]). -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). @@ -85,7 +87,8 @@ all() -> make_invalid_config_release, make_relup_release, make_relup_release2, make_one_app_top_level_release, make_dev_mode_release, make_config_script_release, make_release_twice, make_release_twice_dev_mode, - make_erts_release, make_erts_config_release, make_included_nodetool_release]. + make_erts_release, make_erts_config_release, make_included_nodetool_release, + make_src_release, make_excluded_src_release]. add_providers(Config) -> LibDir1 = proplists:get_value(lib1, Config), @@ -1247,6 +1250,64 @@ make_included_nodetool_release(Config) -> ?assert(lists:keymember(kernel, 1, AppSpecs)), ?assertEqual(ErtsVsn, rlx_release:erts(Release)). +make_src_release(Config) -> + LibDir1 = proplists:get_value(lib1, Config), + + rlx_test_utils:create_app(LibDir1, "goal_app_1", "0.0.1", [kernel,stdlib], []), + rlx_test_utils:create_app(LibDir1, "lib_dep_1", "0.0.1", [kernel,stdlib], []), + rlx_test_utils:create_app(LibDir1, "goal_app_2", "0.0.1", [kernel,stdlib], []), + rlx_test_utils:create_app(LibDir1, "non_goal_1", "0.0.1", [kernel,stdlib], []), + rlx_test_utils:create_app(LibDir1, "non_goal_2", "0.0.1", [kernel,stdlib], []), + + ErtsVsn = erlang:system_info(version), + ConfigFile = filename:join([LibDir1, "relx.config"]), + rlx_test_utils:write_config(ConfigFile, + [{release, {foo, "0.0.1"}, + [goal_app_1]}, + {extended_start_script, true}, + {include_erts, true}, + {include_src, true}]), + OutputDir = filename:join([proplists:get_value(priv_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(ec_file:exists(filename:join([OutputDir, "foo", "erts-"++ErtsVsn, "src"]))), + ?assert(ec_file:exists(filename:join([OutputDir, "foo", "lib", + "goal_app_1-0.0.1", "src"]))). + +make_excluded_src_release(Config) -> + LibDir1 = proplists:get_value(lib1, Config), + + rlx_test_utils:create_app(LibDir1, "goal_app_1", "0.0.1", [kernel,stdlib], []), + rlx_test_utils:create_app(LibDir1, "lib_dep_1", "0.0.1", [kernel,stdlib], []), + rlx_test_utils:create_app(LibDir1, "goal_app_2", "0.0.1", [kernel,stdlib], []), + rlx_test_utils:create_app(LibDir1, "non_goal_1", "0.0.1", [kernel,stdlib], []), + rlx_test_utils:create_app(LibDir1, "non_goal_2", "0.0.1", [kernel,stdlib], []), + + ErtsVsn = erlang:system_info(version), + ConfigFile = filename:join([LibDir1, "relx.config"]), + rlx_test_utils:write_config(ConfigFile, + [{release, {foo, "0.0.1"}, + [goal_app_1]}, + {extended_start_script, true}, + {include_erts, true}, + {include_src, false}]), + OutputDir = filename:join([proplists:get_value(priv_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(not ec_file:exists(filename:join([OutputDir, "foo", "erts-"++ErtsVsn, "src"]))), + ?assert(not ec_file:exists(filename:join([OutputDir, "foo", "lib", + "goal_app_1-0.0.1", "src"]))). + %%%=================================================================== %%% Helper Functions %%%=================================================================== diff --git a/test/rlx_test_utils.erl b/test/rlx_test_utils.erl index 2e6045f..b6f6d7e 100644 --- a/test/rlx_test_utils.erl +++ b/test/rlx_test_utils.erl @@ -7,6 +7,7 @@ create_app(Dir, Name, Vsn, Deps, LibDeps) -> AppDir = filename:join([Dir, Name ++ "-" ++ Vsn]), write_app_file(AppDir, Name, Vsn, Deps, LibDeps), + write_src_file(AppDir, Name), write_beam_file(AppDir, Name), rlx_app_info:new(erlang:list_to_atom(Name), Vsn, AppDir, Deps, []). @@ -22,6 +23,11 @@ write_beam_file(Dir, Name) -> ok = filelib:ensure_dir(Beam), ok = ec_file:write_term(Beam, testing_purposes_only). +write_src_file(Dir, Name) -> + Src = filename:join([Dir, "src", "not_a_real_beam" ++ Name ++ ".erl"]), + ok = filelib:ensure_dir(Src), + ok = ec_file:write_term(Src, testing_purposes_only). + write_appup_file(AppInfo, DownVsn) -> Dir = rlx_app_info:dir(AppInfo), Name = rlx_util:to_string(rlx_app_info:name(AppInfo)), |