From 633dafafc365331af94372bb667b376a42ae913e Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 20 Feb 2015 08:42:38 -0600 Subject: release and tar tests --- test/rebar_release_SUITE.erl | 52 ++++++++++++++++++++++++++++++++++++++++++++ test/rebar_test_utils.erl | 24 ++++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 test/rebar_release_SUITE.erl (limited to 'test') diff --git a/test/rebar_release_SUITE.erl b/test/rebar_release_SUITE.erl new file mode 100644 index 0000000..92219a5 --- /dev/null +++ b/test/rebar_release_SUITE.erl @@ -0,0 +1,52 @@ +-module(rebar_release_SUITE). +-compile(export_all). +-include_lib("common_test/include/ct.hrl"). +-include_lib("eunit/include/eunit.hrl"). + +all() -> [release, tar]. + +init_per_testcase(Case, Config0) -> + Config = rebar_test_utils:init_rebar_state(Config0), + Name = rebar_test_utils:create_random_name(atom_to_list(Case)), + AppDir = ?config(apps, Config), + application:load(rebar), + + ok = ec_file:mkdir_p(AppDir), + State = rebar_state:new([{base_dir, filename:join([AppDir, "_build"])}]), + + rebar_test_utils:create_app(AppDir, Name, "1.0.0", [kernel, stdlib]), + [{name, Name}, {apps, AppDir}, {state, State} | Config]. + +end_per_testcase(_, Config) -> + meck:unload(), + Config. + +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]}]}])), + rebar_test_utils:run_and_check( + Config, RebarConfig, + ["release"], + {ok, [{release, list_to_atom(Name), Vsn}]} + ). + +tar(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]}]}])), + rebar_test_utils:run_and_check( + Config, RebarConfig, + ["tar"], + {ok, [{release, list_to_atom(Name), Vsn}, {tar, Name, Vsn}]} + ). diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl index 96200a6..2198384 100644 --- a/test/rebar_test_utils.erl +++ b/test/rebar_test_utils.erl @@ -115,6 +115,7 @@ check_results(AppDir, Expected) -> DepsNames = [{ec_cnv:to_list(rebar_app_info:name(App)), App} || App <- Deps], Checkouts = rebar_app_discover:find_apps([CheckoutsDir], all), CheckoutsNames = [{ec_cnv:to_list(rebar_app_info:name(App)), App} || App <- Checkouts], + lists:foreach( fun({app, Name}) -> ct:pal("Name: ~p", [Name]), @@ -167,6 +168,29 @@ check_results(AppDir, Expected) -> ?assertEqual(iolist_to_binary(Vsn), iolist_to_binary(LockVsn)) end + ; ({release, Name, Vsn}) -> + ct:pal("Release: ~p-~s", [Name, Vsn]), + {ok, Cwd} = file:get_cwd(), + try + file:set_cwd(AppDir), + ReleaseDir = filename:join([AppDir, "_build", "rel"]), + RelxState = rlx_state:new("", [], []), + RelxState1 = rlx_state:base_output_dir(RelxState, ReleaseDir), + {ok, RelxState2} = rlx_prv_app_discover:do(RelxState1), + {ok, RelxState3} = rlx_prv_rel_discover:do(RelxState2), + + %% throws not_found if it doesn't exist + rlx_state:get_realized_release(RelxState3, Name, Vsn) + catch + _ -> + ct:fail(release_not_found) + after + file:set_cwd(Cwd) + end + ; ({tar, Name, Vsn}) -> + ct:pal("Tarball: ~s-~s", [Name, Vsn]), + TarballWildcard = filename:join([AppDir, "**", Name++"-"++Vsn++".tar.gz"]), + ?assertNotEqual([], filelib:wildcard(TarballWildcard)) end, Expected). write_src_file(Dir, Name) -> -- cgit v1.1 From bf707339811c183e17da661800174c2173a17b05 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sun, 22 Feb 2015 13:28:26 -0600 Subject: fix test, remove use of filelib:wildcard for R15 support --- test/rebar_test_utils.erl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl index 2198384..73b9903 100644 --- a/test/rebar_test_utils.erl +++ b/test/rebar_test_utils.erl @@ -189,8 +189,8 @@ check_results(AppDir, Expected) -> end ; ({tar, Name, Vsn}) -> ct:pal("Tarball: ~s-~s", [Name, Vsn]), - TarballWildcard = filename:join([AppDir, "**", Name++"-"++Vsn++".tar.gz"]), - ?assertNotEqual([], filelib:wildcard(TarballWildcard)) + Tarball = filename:join([AppDir, "_build", "rel", Name, Name++"-"++Vsn++".tar.gz"]), + ?assertNotEqual([], filelib:is_file(Tarball)) end, Expected). write_src_file(Dir, Name) -> -- cgit v1.1