summaryrefslogtreecommitdiff
path: root/test/rebar_deps_SUITE.erl
diff options
context:
space:
mode:
Diffstat (limited to 'test/rebar_deps_SUITE.erl')
-rw-r--r--test/rebar_deps_SUITE.erl130
1 files changed, 62 insertions, 68 deletions
diff --git a/test/rebar_deps_SUITE.erl b/test/rebar_deps_SUITE.erl
index ae50ea3..8a3362d 100644
--- a/test/rebar_deps_SUITE.erl
+++ b/test/rebar_deps_SUITE.erl
@@ -188,27 +188,27 @@ deps(flat) ->
[],
{ok, ["B", "C"]}};
deps(pick_highest_left) ->
- {[{"B", [{"C", "2", []}]},
- {"C", "1", []}],
- [{"C","2"}],
- {ok, ["B", {"C", "1"}]}};
+ {[{"B", [{"C", "2.0.0", []}]},
+ {"C", "1.0.0", []}],
+ [{"C","2.0.0"}],
+ {ok, ["B", {"C", "1.0.0"}]}};
deps(pick_highest_right) ->
- {[{"B", "1", []},
- {"C", [{"B", "2", []}]}],
- [{"B","2"}],
- {ok, [{"B","1"}, "C"]}};
+ {[{"B", "1.0.0", []},
+ {"C", [{"B", "2.0.0", []}]}],
+ [{"B","2.0.0"}],
+ {ok, [{"B","1.0.0"}, "C"]}};
deps(pick_smallest1) ->
- {[{"B", [{"D", "1", []}]},
- {"C", [{"D", "2", []}]}],
- [{"D","2"}],
+ {[{"B", [{"D", "1.0.0", []}]},
+ {"C", [{"D", "2.0.0", []}]}],
+ [{"D","2.0.0"}],
%% we pick D1 because B < C
- {ok, ["B","C",{"D","1"}]}};
+ {ok, ["B","C",{"D","1.0.0"}]}};
deps(pick_smallest2) ->
- {[{"C", [{"D", "2", []}]},
- {"B", [{"D", "1", []}]}],
- [{"D","2"}],
+ {[{"C", [{"D", "2.0.0", []}]},
+ {"B", [{"D", "1.0.0", []}]}],
+ [{"D","2.0.0"}],
%% we pick D1 because B < C
- {ok, ["B","C",{"D","1"}]}};
+ {ok, ["B","C",{"D","1.0.0"}]}};
deps(circular1) ->
{[{"B", [{"A", []}]}, % A is the top-level app
{"C", []}],
@@ -222,15 +222,17 @@ deps(circular2) ->
deps(circular_skip) ->
%% Never spot the circular dep due to being to low in the deps tree
%% in source deps
- {[{"B", [{"C", "2", [{"B", []}]}]},
- {"C", "1", [{"D",[]}]}],
- [{"C","2"}],
- {ok, ["B", {"C","1"}, "D"]}}.
+ {[{"B", [{"C", "2.0.0", [{"B", []}]}]},
+ {"C", "1.0.0", [{"D",[]}]}],
+ [{"C","2.0.0"}],
+ {ok, ["B", {"C","1.0.0"}, "D"]}}.
setup_project(Case, Config0, Deps) ->
DepsType = ?config(deps_type, Config0),
+ %% spread packages across 3 repos randomly
+ Repos = [<<"test-repo-1">>, <<"test-repo-2">>, <<"hexpm">>],
Config = rebar_test_utils:init_rebar_state(
- Config0,
+ [{repos, Repos} | Config0],
atom_to_list(Case)++"_"++atom_to_list(DepsType)++"_"
),
AppDir = ?config(apps, Config),
@@ -239,7 +241,7 @@ setup_project(Case, Config0, Deps) ->
RebarConf = rebar_test_utils:create_config(AppDir, [{deps, TopDeps}]),
{SrcDeps, PkgDeps} = rebar_test_utils:flat_deps(Deps),
mock_git_resource:mock([{deps, SrcDeps}]),
- mock_pkg_resource:mock([{pkgdeps, PkgDeps}]),
+ mock_pkg_resource:mock([{pkgdeps, PkgDeps}, {repos, Repos}]),
[{rebarconfig, RebarConf} | Config].
mock_warnings() ->
@@ -412,70 +414,62 @@ https_os_proxy_settings(_Config) ->
httpc:get_option(https_proxy, rebar)).
semver_matching_lt(_Config) ->
- Dep = <<"test">>,
- Dep1 = {Dep, <<"1.0.0">>, Dep, Dep},
MaxVsn = <<"0.2.0">>,
Vsns = [<<"0.1.7">>, <<"0.1.9">>, <<"0.1.8">>, <<"0.2.0">>, <<"0.2.1">>],
- ?assertEqual([{Dep, {pkg, Dep, <<"0.1.9">>, undefined}}],
- rebar_prv_update:cmpl_(undefined, MaxVsn, Vsns, [], Dep1,
+ ?assertEqual({ok, <<"0.1.9">>},
+ rebar_packages:cmpl_(undefined, MaxVsn, Vsns,
fun ec_semver:lt/2)).
semver_matching_lte(_Config) ->
- Dep = <<"test">>,
- Dep1 = {Dep, <<"1.0.0">>, Dep, Dep},
MaxVsn = <<"0.2.0">>,
Vsns = [<<"0.1.7">>, <<"0.1.9">>, <<"0.1.8">>, <<"0.2.0">>, <<"0.2.1">>],
- ?assertEqual([{Dep, {pkg, Dep, <<"0.2.0">>, undefined}}],
- rebar_prv_update:cmpl_(undefined, MaxVsn, Vsns, [], Dep1,
+ ?assertEqual({ok, <<"0.2.0">>},
+ rebar_packages:cmpl_(undefined, MaxVsn, Vsns,
fun ec_semver:lte/2)).
semver_matching_gt(_Config) ->
- Dep = <<"test">>,
- Dep1 = {Dep, <<"1.0.0">>, Dep, Dep},
MaxVsn = <<"0.2.0">>,
Vsns = [<<"0.1.7">>, <<"0.1.9">>, <<"0.1.8">>, <<"0.2.0">>, <<"0.2.1">>],
- ?assertEqual([{Dep, {pkg, Dep, <<"0.2.1">>, undefined}}],
- rebar_prv_update:cmp_(undefined, MaxVsn, Vsns, [], Dep1,
+ ?assertEqual({ok, <<"0.2.1">>},
+ rebar_packages:cmp_(undefined, MaxVsn, Vsns,
fun ec_semver:gt/2)).
semver_matching_gte(_Config) ->
- Dep = <<"test">>,
- Dep1 = {Dep, <<"1.0.0">>, Dep, Dep},
MaxVsn = <<"0.2.0">>,
Vsns = [<<"0.1.7">>, <<"0.1.9">>, <<"0.1.8">>, <<"0.2.0">>],
- ?assertEqual([{Dep, {pkg, Dep, <<"0.2.0">>, undefined}}],
- rebar_prv_update:cmp_(undefined, MaxVsn, Vsns, [], Dep1,
+ ?assertEqual({ok, <<"0.2.0">>},
+ rebar_packages:cmp_(undefined, MaxVsn, Vsns,
fun ec_semver:gt/2)).
valid_version(_Config) ->
- ?assert(rebar_prv_update:valid_vsn(<<"0.1">>)),
- ?assert(rebar_prv_update:valid_vsn(<<"0.1.0">>)),
- ?assert(rebar_prv_update:valid_vsn(<<" 0.1.0">>)),
- ?assert(rebar_prv_update:valid_vsn(<<" 0.1.0">>)),
- ?assert(rebar_prv_update:valid_vsn(<<"<0.1">>)),
- ?assert(rebar_prv_update:valid_vsn(<<"<0.1.0">>)),
- ?assert(rebar_prv_update:valid_vsn(<<"< 0.1.0">>)),
- ?assert(rebar_prv_update:valid_vsn(<<"< 0.1.0">>)),
- ?assert(rebar_prv_update:valid_vsn(<<">0.1">>)),
- ?assert(rebar_prv_update:valid_vsn(<<">0.1.0">>)),
- ?assert(rebar_prv_update:valid_vsn(<<"> 0.1.0">>)),
- ?assert(rebar_prv_update:valid_vsn(<<"> 0.1.0">>)),
- ?assert(rebar_prv_update:valid_vsn(<<"<=0.1">>)),
- ?assert(rebar_prv_update:valid_vsn(<<"<=0.1.0">>)),
- ?assert(rebar_prv_update:valid_vsn(<<"<= 0.1.0">>)),
- ?assert(rebar_prv_update:valid_vsn(<<"<= 0.1.0">>)),
- ?assert(rebar_prv_update:valid_vsn(<<">=0.1">>)),
- ?assert(rebar_prv_update:valid_vsn(<<">=0.1.0">>)),
- ?assert(rebar_prv_update:valid_vsn(<<">= 0.1.0">>)),
- ?assert(rebar_prv_update:valid_vsn(<<">= 0.1.0">>)),
- ?assert(rebar_prv_update:valid_vsn(<<"==0.1">>)),
- ?assert(rebar_prv_update:valid_vsn(<<"==0.1.0">>)),
- ?assert(rebar_prv_update:valid_vsn(<<"== 0.1.0">>)),
- ?assert(rebar_prv_update:valid_vsn(<<"== 0.1.0">>)),
- ?assert(rebar_prv_update:valid_vsn(<<"~>0.1">>)),
- ?assert(rebar_prv_update:valid_vsn(<<"~>0.1.0">>)),
- ?assert(rebar_prv_update:valid_vsn(<<"~> 0.1.0">>)),
- ?assert(rebar_prv_update:valid_vsn(<<"~> 0.1.0">>)),
- ?assertNot(rebar_prv_update:valid_vsn(<<"> 0.1.0 and < 0.2.0">>)),
+ ?assert(rebar_packages:valid_vsn(<<"0.1">>)),
+ ?assert(rebar_packages:valid_vsn(<<"0.1.0">>)),
+ ?assert(rebar_packages:valid_vsn(<<" 0.1.0">>)),
+ ?assert(rebar_packages:valid_vsn(<<" 0.1.0">>)),
+ ?assert(rebar_packages:valid_vsn(<<"<0.1">>)),
+ ?assert(rebar_packages:valid_vsn(<<"<0.1.0">>)),
+ ?assert(rebar_packages:valid_vsn(<<"< 0.1.0">>)),
+ ?assert(rebar_packages:valid_vsn(<<"< 0.1.0">>)),
+ ?assert(rebar_packages:valid_vsn(<<">0.1">>)),
+ ?assert(rebar_packages:valid_vsn(<<">0.1.0">>)),
+ ?assert(rebar_packages:valid_vsn(<<"> 0.1.0">>)),
+ ?assert(rebar_packages:valid_vsn(<<"> 0.1.0">>)),
+ ?assert(rebar_packages:valid_vsn(<<"<=0.1">>)),
+ ?assert(rebar_packages:valid_vsn(<<"<=0.1.0">>)),
+ ?assert(rebar_packages:valid_vsn(<<"<= 0.1.0">>)),
+ ?assert(rebar_packages:valid_vsn(<<"<= 0.1.0">>)),
+ ?assert(rebar_packages:valid_vsn(<<">=0.1">>)),
+ ?assert(rebar_packages:valid_vsn(<<">=0.1.0">>)),
+ ?assert(rebar_packages:valid_vsn(<<">= 0.1.0">>)),
+ ?assert(rebar_packages:valid_vsn(<<">= 0.1.0">>)),
+ ?assert(rebar_packages:valid_vsn(<<"==0.1">>)),
+ ?assert(rebar_packages:valid_vsn(<<"==0.1.0">>)),
+ ?assert(rebar_packages:valid_vsn(<<"== 0.1.0">>)),
+ ?assert(rebar_packages:valid_vsn(<<"== 0.1.0">>)),
+ ?assert(rebar_packages:valid_vsn(<<"~>0.1">>)),
+ ?assert(rebar_packages:valid_vsn(<<"~>0.1.0">>)),
+ ?assert(rebar_packages:valid_vsn(<<"~> 0.1.0">>)),
+ ?assert(rebar_packages:valid_vsn(<<"~> 0.1.0">>)),
+ ?assertNot(rebar_packages:valid_vsn(<<"> 0.1.0 and < 0.2.0">>)),
ok.
@@ -504,5 +498,5 @@ in_warnings(git, Warns, NameRaw, VsnRaw) ->
in_warnings(pkg, Warns, NameRaw, VsnRaw) ->
Name = iolist_to_binary(NameRaw),
Vsn = iolist_to_binary(VsnRaw),
- 1 =< length([1 || {_, [AppName, {pkg, _, AppVsn, _}]} <- Warns,
+ 1 =< length([1 || {_, [AppName, {pkg, _, AppVsn}]} <- Warns,
AppName =:= Name, AppVsn =:= Vsn]).