Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add tests for release provider testing --all and --relnames options #10

Merged
merged 2 commits into from
Nov 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions releases_test/apps/app1/src/app1.app.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{application, app1,
[{description, "An OTP application"},
{vsn, "0.1.0"},
{registered, []},
{mod, {app1_app, []}},
{applications,
[kernel,
stdlib
]}
]}.
18 changes: 18 additions & 0 deletions releases_test/apps/app1/src/app1_app.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
%%%-------------------------------------------------------------------
%% @doc app1 public API
%% @end
%%%-------------------------------------------------------------------

-module(app1_app).

-behaviour(application).

-export([start/2, stop/1]).

start(_StartType, _StartArgs) ->
app1_sup:start_link().

stop(_State) ->
ok.

%% internal functions
35 changes: 35 additions & 0 deletions releases_test/apps/app1/src/app1_sup.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
%%%-------------------------------------------------------------------
%% @doc app1 top level supervisor.
%% @end
%%%-------------------------------------------------------------------

-module(app1_sup).

-behaviour(supervisor).

-export([start_link/0]).

-export([init/1]).

-define(SERVER, ?MODULE).

start_link() ->
supervisor:start_link({local, ?SERVER}, ?MODULE, []).

%% sup_flags() = #{strategy => strategy(), % optional
%% intensity => non_neg_integer(), % optional
%% period => pos_integer()} % optional
%% child_spec() = #{id => child_id(), % mandatory
%% start => mfargs(), % mandatory
%% restart => restart(), % optional
%% shutdown => shutdown(), % optional
%% type => worker(), % optional
%% modules => modules()} % optional
init([]) ->
SupFlags = #{strategy => one_for_all,
intensity => 0,
period => 1},
ChildSpecs = [],
{ok, {SupFlags, ChildSpecs}}.

%% internal functions
10 changes: 10 additions & 0 deletions releases_test/apps/app2/src/app2.app.src
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{application, app2,
[{description, "An OTP application"},
{vsn, "0.1.0"},
{registered, []},
{mod, {app2_app, []}},
{applications,
[kernel,
stdlib
]}
]}.
18 changes: 18 additions & 0 deletions releases_test/apps/app2/src/app2_app.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
%%%-------------------------------------------------------------------
%% @doc app2 public API
%% @end
%%%-------------------------------------------------------------------

-module(app2_app).

-behaviour(application).

-export([start/2, stop/1]).

start(_StartType, _StartArgs) ->
app2_sup:start_link().

stop(_State) ->
ok.

%% internal functions
35 changes: 35 additions & 0 deletions releases_test/apps/app2/src/app2_sup.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
%%%-------------------------------------------------------------------
%% @doc app2 top level supervisor.
%% @end
%%%-------------------------------------------------------------------

-module(app2_sup).

-behaviour(supervisor).

-export([start_link/0]).

-export([init/1]).

-define(SERVER, ?MODULE).

start_link() ->
supervisor:start_link({local, ?SERVER}, ?MODULE, []).

%% sup_flags() = #{strategy => strategy(), % optional
%% intensity => non_neg_integer(), % optional
%% period => pos_integer()} % optional
%% child_spec() = #{id => child_id(), % mandatory
%% start => mfargs(), % mandatory
%% restart => restart(), % optional
%% shutdown => shutdown(), % optional
%% type => worker(), % optional
%% modules => modules()} % optional
init([]) ->
SupFlags = #{strategy => one_for_all,
intensity => 0,
period => 1},
ChildSpecs = [],
{ok, {SupFlags, ChildSpecs}}.

%% internal functions
3 changes: 3 additions & 0 deletions releases_test/config/sys.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[
{releases_test, []}
].
6 changes: 6 additions & 0 deletions releases_test/config/vm.args
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-sname releases_test

-setcookie releases_test_cookie

+K true
+A30
17 changes: 17 additions & 0 deletions releases_test/rebar.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{erl_opts, [debug_info]}.
{deps, []}.

{relx, [{release, {app1, "0.1.0"},
[app1, sasl]},
{release, {app1, "0.2.0"},
[app1, sasl]},
{release, {app2, "0.1.0"},
[app2, sasl]},
{release, {both, "0.1.0"},
[app1, app2, sasl]},

{mode, dev},

{sys_config, "./config/sys.config"},
{vm_args, "./config/vm.args"}
]}.
1 change: 1 addition & 0 deletions releases_test/rebar.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[].
8 changes: 8 additions & 0 deletions releases_test/releases.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
rebar3 release
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should add a check that the output includes the expected error message:

Must specify the name of the release to build when there are multiple releases in the config

>>>= 1
rebar3 release --relname app1
>>>= 0
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but just to be sure can you add a test to verify the release is built, like:

ls _build/default/rel/app1/releases
>>>= 0

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, makes a lot of sense!

rebar3 release --relnames app1,both
>>>= 0
rebar3 release --all
>>>= 0