From 81969f1cf68f9509ee1bb18a15695b610fd33bd7 Mon Sep 17 00:00:00 2001 From: Kelly McLaughlin Date: Sun, 22 Mar 2015 22:09:27 -0600 Subject: Test cases to exercise the dev_mode release option Add one test case to verify the dev_mode option for a release and another to verify overriding the dev_mode option in a profile for a release. Verification of proper dev_mode functioning is done in the rebar_test_utils:check_results/2 function by checking if all the directories in the release lib dir are symlinks or not and comparing that result to the dev_mode expectation passed as input to the check_results function. --- test/rebar_release_SUITE.erl | 46 +++++++++++++++++++++++++++++++++++++++++--- test/rebar_test_utils.erl | 11 ++++++++++- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/test/rebar_release_SUITE.erl b/test/rebar_release_SUITE.erl index 92219a5..3809106 100644 --- a/test/rebar_release_SUITE.erl +++ b/test/rebar_release_SUITE.erl @@ -3,7 +3,10 @@ -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). -all() -> [release, tar]. +all() -> [release, + dev_mode_release, + profile_dev_mode_override_release, + tar]. init_per_testcase(Case, Config0) -> Config = rebar_test_utils:init_rebar_state(Config0), @@ -33,9 +36,46 @@ release(Config) -> rebar_test_utils:run_and_check( Config, RebarConfig, ["release"], - {ok, [{release, list_to_atom(Name), Vsn}]} + {ok, [{release, list_to_atom(Name), Vsn, false}]} ). +dev_mode_release(Config) -> + AppDir = ?config(apps, Config), + Name = ?config(name, Config), + Vsn = "1.0.0", + {ok, RebarConfig} = + file:consult(rebar_test_utils:create_config(AppDir, + [{relx, [{release, {list_to_atom(Name), Vsn}, + [list_to_atom(Name)]}, + {lib_dirs, [AppDir]}, + {dev_mode, true}]}])), + rebar_test_utils:run_and_check( + Config, RebarConfig, + ["release"], + {ok, [{release, list_to_atom(Name), Vsn, true}]} + ). + + +profile_dev_mode_override_release(Config) -> + AppDir = ?config(apps, Config), + Name = ?config(name, Config), + Vsn = "1.0.0", + {ok, RebarConfig} = + file:consult(rebar_test_utils:create_config(AppDir, + [{relx, [{release, {list_to_atom(Name), Vsn}, + [list_to_atom(Name)]}, + {lib_dirs, [AppDir]}, + {dev_mode, true}]}, + {profiles, + [{ct, + [{relx, [{dev_mode, false}]}]}]}])), + rebar_test_utils:run_and_check( + Config, RebarConfig, + ["as", "ct", "release"], + {ok, [{release, list_to_atom(Name), Vsn, false}]} + ). + + tar(Config) -> AppDir = ?config(apps, Config), Name = ?config(name, Config), @@ -48,5 +88,5 @@ tar(Config) -> rebar_test_utils:run_and_check( Config, RebarConfig, ["tar"], - {ok, [{release, list_to_atom(Name), Vsn}, {tar, Name, Vsn}]} + {ok, [{release, list_to_atom(Name), Vsn, false}, {tar, Name, Vsn}]} ). diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl index 7c52a18..c035b91 100644 --- a/test/rebar_test_utils.erl +++ b/test/rebar_test_utils.erl @@ -217,7 +217,7 @@ check_results(AppDir, Expected) -> ?assertEqual(iolist_to_binary(Vsn), iolist_to_binary(LockVsn)) end - ; ({release, Name, Vsn}) -> + ; ({release, Name, Vsn, ExpectedDevMode}) -> ct:pal("Release: ~p-~s", [Name, Vsn]), {ok, Cwd} = file:get_cwd(), try @@ -228,6 +228,15 @@ check_results(AppDir, Expected) -> {ok, RelxState2} = rlx_prv_app_discover:do(RelxState1), {ok, RelxState3} = rlx_prv_rel_discover:do(RelxState2), + LibDir = filename:join([ReleaseDir, Name, "lib"]), + {ok, RelLibs} = file:list_dir(LibDir), + IsSymLinkFun = + fun(X) -> + ec_file:is_symlink(filename:join(LibDir, X)) + end, + DevMode = lists:all(IsSymLinkFun, RelLibs), + ?assertEqual(ExpectedDevMode, DevMode), + %% throws not_found if it doesn't exist rlx_state:get_realized_release(RelxState3, Name, Vsn) catch -- cgit v1.1