summaryrefslogtreecommitdiff
path: root/test/rebar_install_deps_SUITE.erl
diff options
context:
space:
mode:
Diffstat (limited to 'test/rebar_install_deps_SUITE.erl')
-rw-r--r--test/rebar_install_deps_SUITE.erl86
1 files changed, 72 insertions, 14 deletions
diff --git a/test/rebar_install_deps_SUITE.erl b/test/rebar_install_deps_SUITE.erl
index d1a1118..be42e68 100644
--- a/test/rebar_install_deps_SUITE.erl
+++ b/test/rebar_install_deps_SUITE.erl
@@ -10,7 +10,8 @@ groups() ->
[{all, [], [flat, pick_highest_left, pick_highest_right,
pick_smallest1, pick_smallest2,
circular1, circular2, circular_skip,
- fail_conflict, default_profile, nondefault_profile]},
+ fail_conflict, default_profile, nondefault_profile,
+ nondefault_pick_highest]},
{git, [], [{group, all}]},
{pkg, [], [{group, all}]}].
@@ -48,10 +49,10 @@ end_per_testcase(_, Config) ->
Config.
format_expected_deps(Deps) ->
- [case Dep of
- {N,V} -> {dep, N, V};
- N -> {dep, N}
- end || Dep <- Deps].
+ lists:append([case Dep of
+ {N,V} -> [{dep, N, V}, {lock, N, V}];
+ N -> [{dep, N}, {lock, N}]
+ end || Dep <- Deps]).
%% format:
%% {Spec,
@@ -125,7 +126,10 @@ deps(nondefault_profile) ->
{[{"B", []},
{"C", []}],
[],
- {ok, ["B", "C"]}}.
+ {ok, ["B", "C"]}};
+deps(nondefault_pick_highest) ->
+ %% This is all handled in setup_project
+ {[],[],{ok,[]}}.
setup_project(fail_conflict, Config0, Deps) ->
DepsType = ?config(deps_type, Config0),
@@ -164,6 +168,34 @@ setup_project(nondefault_profile, Config0, Deps) ->
mock_pkg_resource:mock([{pkgdeps, rebar_test_utils:flat_pkgdeps(Deps)}])
end,
[{rebarconfig, RebarConf} | Config];
+setup_project(nondefault_pick_highest, Config0, _) ->
+ DepsType = ?config(deps_type, Config0),
+ Config = rebar_test_utils:init_rebar_state(
+ Config0,
+ "nondefault_pick_highest_"++atom_to_list(DepsType)++"_"
+ ),
+ AppDir = ?config(apps, Config),
+ rebar_test_utils:create_app(AppDir, "A", "0.0.0", [kernel, stdlib]),
+ DefaultDeps = rebar_test_utils:expand_deps(DepsType, [{"B", [{"C", "1", []}]}]),
+ ProfileDeps = rebar_test_utils:expand_deps(DepsType, [{"C", "2", []}]),
+ DefaultTop = rebar_test_utils:top_level_deps(DefaultDeps),
+ ProfileTop = rebar_test_utils:top_level_deps(ProfileDeps),
+ RebarConf = rebar_test_utils:create_config(
+ AppDir,
+ [{deps, DefaultTop},
+ {profiles, [{nondef, [{deps, ProfileTop}]}]}]
+ ),
+ case DepsType of
+ git ->
+ mock_git_resource:mock(
+ [{deps, rebar_test_utils:flat_deps(DefaultDeps ++ ProfileDeps)}]
+ );
+ pkg ->
+ mock_pkg_resource:mock(
+ [{pkgdeps, rebar_test_utils:flat_pkgdeps(DefaultDeps ++ ProfileDeps)}]
+ )
+ end,
+ [{rebarconfig, RebarConf} | Config];
setup_project(Case, Config0, Deps) ->
DepsType = ?config(deps_type, Config0),
Config = rebar_test_utils:init_rebar_state(
@@ -200,7 +232,7 @@ circular_skip(Config) -> run(Config).
fail_conflict(Config) ->
{ok, RebarConfig} = file:consult(?config(rebarconfig, Config)),
rebar_test_utils:run_and_check(
- Config, RebarConfig, ["install_deps"], ?config(expect, Config)
+ Config, RebarConfig, ["lock"], ?config(expect, Config)
),
check_warnings(error_calls(), ?config(warnings, Config), ?config(deps_type, Config)).
@@ -209,7 +241,7 @@ default_profile(Config) ->
AppDir = ?config(apps, Config),
{ok, Apps} = Expect = ?config(expect, Config),
rebar_test_utils:run_and_check(
- Config, RebarConfig, ["as", "profile", "install_deps"], Expect
+ Config, RebarConfig, ["as", "profile", "lock"], Expect
),
check_warnings(error_calls(), ?config(warnings, Config), ?config(deps_type, Config)),
BuildDir = filename:join([AppDir, "_build"]),
@@ -221,18 +253,30 @@ default_profile(Config) ->
|| {dep, App} <- Apps],
%% A second run to another profile also links default to the right spot
rebar_test_utils:run_and_check(
- Config, RebarConfig, ["as", "other", "install_deps"], Expect
+ Config, RebarConfig, ["as", "other", "lock"], Expect
),
[?assertMatch({ok, #file_info{type=directory}}, % somehow symlinks return dirs
file:read_file_info(filename:join([BuildDir, "other", "lib", App])))
|| {dep, App} <- Apps].
nondefault_profile(Config) ->
+ %% The dependencies here are saved directly to the
{ok, RebarConfig} = file:consult(?config(rebarconfig, Config)),
AppDir = ?config(apps, Config),
- {ok, Apps} = Expect = ?config(expect, Config),
+ {ok, AppLocks} = ?config(expect, Config),
+ try
+ rebar_test_utils:run_and_check(
+ Config, RebarConfig, ["as", "nondef", "lock"], {ok, AppLocks}
+ ),
+ error(generated_locks)
+ catch
+ error:generated_locks -> error(generated_locks);
+ _:_ -> ok
+ end,
+ Apps = [App || App = {dep, _} <- AppLocks],
+ Expect = {ok, Apps},
rebar_test_utils:run_and_check(
- Config, RebarConfig, ["as", "nondef", "install_deps"], Expect
+ Config, RebarConfig, ["as", "nondef", "lock"], Expect
),
check_warnings(error_calls(), ?config(warnings, Config), ?config(deps_type, Config)),
BuildDir = filename:join([AppDir, "_build"]),
@@ -244,17 +288,32 @@ nondefault_profile(Config) ->
|| {dep, App} <- Apps],
%% A second run to another profile doesn't link dependencies
rebar_test_utils:run_and_check(
- Config, RebarConfig, ["as", "other", "install_deps"], Expect
+ Config, RebarConfig, ["as", "other", "lock"], Expect
),
[?assertMatch({error, enoent},
file:read_file_info(filename:join([BuildDir, "default", "lib", App])))
|| {dep, App} <- Apps].
+nondefault_pick_highest(Config) ->
+ {ok, RebarConfig} = file:consult(?config(rebarconfig, Config)),
+ %AppDir = ?config(apps, Config),
+ rebar_test_utils:run_and_check(
+ Config, RebarConfig, ["as", "nondef", "lock"],
+ {ok, [{dep, "B"}, {lock, "B"}, {dep, "C", "2"}], "nondef"}
+ ),
+ rebar_test_utils:run_and_check(
+ Config, RebarConfig, ["lock"],
+ {ok, [{dep, "B"}, {lock, "B"}, {dep, "C", "1"}, {lock, "C", "1"}], "default"}
+ ),
+ rebar_test_utils:run_and_check(
+ Config, RebarConfig, ["as", "nondef", "lock"],
+ {ok, [{dep, "B"}, {lock, "B"}, {dep, "C", "2"}], "nondef"}
+ ).
run(Config) ->
{ok, RebarConfig} = file:consult(?config(rebarconfig, Config)),
rebar_test_utils:run_and_check(
- Config, RebarConfig, ["install_deps"], ?config(expect, Config)
+ Config, RebarConfig, ["lock"], ?config(expect, Config)
),
check_warnings(warning_calls(), ?config(warnings, Config), ?config(deps_type, Config)).
@@ -282,4 +341,3 @@ in_warnings(pkg, Warns, NameRaw, VsnRaw) ->
Vsn = iolist_to_binary(VsnRaw),
1 =< length([1 || {_, [AppName, AppVsn]} <- Warns,
AppName =:= Name, AppVsn =:= Vsn]).
-