summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/rebar_install_deps_SUITE.erl67
1 files changed, 65 insertions, 2 deletions
diff --git a/test/rebar_install_deps_SUITE.erl b/test/rebar_install_deps_SUITE.erl
index aebd3e3..68fb9dd 100644
--- a/test/rebar_install_deps_SUITE.erl
+++ b/test/rebar_install_deps_SUITE.erl
@@ -2,6 +2,7 @@
-compile(export_all).
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
+-include_lib("kernel/include/file.hrl").
all() -> [{group, git}, {group, pkg}].
@@ -9,7 +10,7 @@ groups() ->
[{all, [], [flat, pick_highest_left, pick_highest_right,
pick_smallest1, pick_smallest2,
circular1, circular2, circular_skip,
- fail_conflict]},
+ fail_conflict, default_profile, nondefault_profile]},
{git, [], [{group, all}]},
{pkg, [], [{group, all}]}].
@@ -114,7 +115,17 @@ deps(fail_conflict) ->
{[{"B", [{"C", "2", []}]},
{"C", "1", []}],
[{"C","2"}],
- rebar_abort}.
+ rebar_abort};
+deps(default_profile) ->
+ {[{"B", []},
+ {"C", []}],
+ [],
+ {ok, ["B", "C"]}};
+deps(nondefault_profile) ->
+ {[{"B", []},
+ {"C", []}],
+ [],
+ {ok, ["B", "C"]}}.
setup_project(fail_conflict, Config0, Deps) ->
DepsType = ?config(deps_type, Config0),
@@ -134,6 +145,25 @@ setup_project(fail_conflict, Config0, Deps) ->
mock_pkg_resource:mock([{pkgdeps, rebar_test_utils:flat_pkgdeps(Deps)}])
end,
[{rebarconfig, RebarConf} | Config];
+setup_project(nondefault_profile, Config0, Deps) ->
+ DepsType = ?config(deps_type, Config0),
+ Config = rebar_test_utils:init_rebar_state(
+ Config0,
+ "nondefault_profile_"++atom_to_list(DepsType)++"_"
+ ),
+ AppDir = ?config(apps, Config),
+ rebar_test_utils:create_app(AppDir, "A", "0.0.0", [kernel, stdlib]),
+ TopDeps = rebar_test_utils:top_level_deps(Deps),
+ RebarConf = rebar_test_utils:create_config(AppDir, [{profiles, [
+ {nondef, [{deps, TopDeps}]}
+ ]}]),
+ case DepsType of
+ git ->
+ mock_git_resource:mock([{deps, rebar_test_utils:flat_deps(Deps)}]);
+ pkg ->
+ mock_pkg_resource:mock([{pkgdeps, rebar_test_utils:flat_pkgdeps(Deps)}])
+ end,
+ [{rebarconfig, RebarConf} | Config];
setup_project(Case, Config0, Deps) ->
DepsType = ?config(deps_type, Config0),
Config = rebar_test_utils:init_rebar_state(
@@ -174,6 +204,39 @@ fail_conflict(Config) ->
),
check_warnings(error_calls(), ?config(warnings, Config), ?config(deps_type, Config)).
+default_profile(Config) ->
+ {ok, RebarConfig} = file:consult(?config(rebarconfig, Config)),
+ AppDir = ?config(apps, Config),
+ {ok, Apps} = Expect = ?config(expect, Config),
+ rebar_test_utils:run_and_check(
+ Config, RebarConfig, ["as", "profile", "install_deps"], Expect
+ ),
+ check_warnings(error_calls(), ?config(warnings, Config), ?config(deps_type, Config)),
+ BuildDir = filename:join([AppDir, "_build"]),
+ [?assertMatch({ok, #file_info{type=directory}},
+ file:read_file_info(filename:join([BuildDir, "default", "lib", App])))
+ || {dep, App} <- Apps],
+ [?assertMatch({ok, #file_info{type=directory}}, % somehow symlinks return dirs
+ file:read_file_info(filename:join([BuildDir, "profile", "lib", App])))
+ || {dep, App} <- Apps].
+
+nondefault_profile(Config) ->
+ {ok, RebarConfig} = file:consult(?config(rebarconfig, Config)),
+ AppDir = ?config(apps, Config),
+ {ok, Apps} = Expect = ?config(expect, Config),
+ rebar_test_utils:run_and_check(
+ Config, RebarConfig, ["as", "nondef", "install_deps"], Expect
+ ),
+ check_warnings(error_calls(), ?config(warnings, Config), ?config(deps_type, Config)),
+ BuildDir = filename:join([AppDir, "_build"]),
+ [?assertMatch({error, enoent},
+ file:read_file_info(filename:join([BuildDir, "default", "lib", App])))
+ || {dep, App} <- Apps],
+ [?assertMatch({ok, #file_info{type=directory}},
+ file:read_file_info(filename:join([BuildDir, "nondef", "lib", App])))
+ || {dep, App} <- Apps].
+
+
run(Config) ->
{ok, RebarConfig} = file:consult(?config(rebarconfig, Config)),
rebar_test_utils:run_and_check(