diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/rebar_as_SUITE.erl | 22 | ||||
-rw-r--r-- | test/rebar_opts_parser_SUITE.erl | 54 | ||||
-rw-r--r-- | test/rebar_profiles_SUITE.erl | 11 | ||||
-rw-r--r-- | test/rebar_release_SUITE.erl | 46 | ||||
-rw-r--r-- | test/rebar_test_utils.erl | 11 |
5 files changed, 136 insertions, 8 deletions
diff --git a/test/rebar_as_SUITE.erl b/test/rebar_as_SUITE.erl index 864d468..1d1112b 100644 --- a/test/rebar_as_SUITE.erl +++ b/test/rebar_as_SUITE.erl @@ -11,7 +11,8 @@ as_multiple_profiles_multiple_tasks/1, as_comma_placement/1, as_comma_then_space/1, - as_dir_name/1]). + as_dir_name/1, + as_with_task_args/1]). -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). @@ -29,7 +30,7 @@ init_per_testcase(_, Config) -> all() -> [as_basic, as_multiple_profiles, as_multiple_tasks, as_multiple_profiles_multiple_tasks, as_comma_placement, as_comma_then_space, - as_dir_name]. + as_dir_name, as_with_task_args]. as_basic(Config) -> AppDir = ?config(apps, Config), @@ -118,3 +119,20 @@ as_dir_name(Config) -> true = filelib:is_dir(filename:join([AppDir, "_build", "foo+bar+baz"])). + +as_with_task_args(Config) -> + AppDir = ?config(apps, Config), + + Name = rebar_test_utils:create_random_name("as_with_task_args_"), + Vsn = rebar_test_utils:create_random_vsn(), + rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]), + + rebar_test_utils:run_and_check(Config, + [], + ["as", "default", "compile"], + {ok, [{app, Name}]}), + + rebar_test_utils:run_and_check(Config, + [], + ["as", "default", "clean", "-a"], + {ok, [{app, Name, invalid}]}). diff --git a/test/rebar_opts_parser_SUITE.erl b/test/rebar_opts_parser_SUITE.erl new file mode 100644 index 0000000..fc738b9 --- /dev/null +++ b/test/rebar_opts_parser_SUITE.erl @@ -0,0 +1,54 @@ +-module(rebar_opts_parser_SUITE). + +-export([all/0, init_per_testcase/2]). +-export([bad_arg_to_flag/1, missing_arg_to_flag/1]). + +-include_lib("common_test/include/ct.hrl"). + + +all() -> [bad_arg_to_flag, missing_arg_to_flag]. + +init_per_testcase(_, Config) -> + rebar_test_utils:init_rebar_state(Config, "opts_parser_"). + +bad_arg_to_flag(Config) -> + ok = meck:new(getopt), + ok = meck:expect(getopt, + parse, + fun(_, _) -> {error, {invalid_option_arg, {foo, "null"}}} end), + + AppDir = ?config(apps, Config), + + Name = rebar_test_utils:create_random_name("bad_arg_"), + Vsn = rebar_test_utils:create_random_vsn(), + rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]), + + {error, Error} = rebar_test_utils:run_and_check(Config, + [], + ["compile", "--foo=null"], + return), + + true = meck:validate(getopt), + ok = meck:unload(getopt), + + "Invalid argument null to option foo" = lists:flatten(Error). + +missing_arg_to_flag(Config) -> + ok = meck:new(getopt), + ok = meck:expect(getopt, parse, fun(_, _) -> {error, {missing_option_arg, foo}} end), + + AppDir = ?config(apps, Config), + + Name = rebar_test_utils:create_random_name("missing_arg_"), + Vsn = rebar_test_utils:create_random_vsn(), + rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]), + + {error, Error} = rebar_test_utils:run_and_check(Config, + [], + ["compile", "--foo"], + return), + + true = meck:validate(getopt), + ok = meck:unload(getopt), + + "Missing argument to option foo" = lists:flatten(Error).
\ No newline at end of file diff --git a/test/rebar_profiles_SUITE.erl b/test/rebar_profiles_SUITE.erl index a4f926e..ab37255 100644 --- a/test/rebar_profiles_SUITE.erl +++ b/test/rebar_profiles_SUITE.erl @@ -100,12 +100,17 @@ profile_merges(_Config) -> {test2, "hello"}, {test3, [key3]}, {test4, "oldvalue"}, + {test5, [{key5, true}]}, + {test6, [{key6, false}]}, {profiles, [{profile1, [{test1, [{key3, 5}, key1]}]}, {profile2, [{test2, "goodbye"}, {test3, []}, - {test4, []}]}]}], + {test4, []}, + {test5, [{key5, false}]}, + {test6, [{key6, true}]} + ]}]}], State = rebar_state:new(RebarConfig), State1 = rebar_state:apply_profiles(State, [profile1, profile2]), @@ -118,7 +123,9 @@ profile_merges(_Config) -> %% Check that a newvalue of []/"" doesn't override non-string oldvalues [key3] = rebar_state:get(State1, test3), - [] = rebar_state:get(State1, test4). + [] = rebar_state:get(State1, test4), + [{key5, false}, {key5, true}] = rebar_state:get(State1, test5), + [{key6, true}, {key6, false}] = rebar_state:get(State1, test6). add_to_profile(_Config) -> RebarConfig = [{foo, true}, {bar, false}], 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 0497dd0..7d57e0d 100644 --- a/test/rebar_test_utils.erl +++ b/test/rebar_test_utils.erl @@ -218,7 +218,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 @@ -229,6 +229,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 |