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.erl56
1 files changed, 4 insertions, 52 deletions
diff --git a/test/rebar_install_deps_SUITE.erl b/test/rebar_install_deps_SUITE.erl
index 5e56029..28cc277 100644
--- a/test/rebar_install_deps_SUITE.erl
+++ b/test/rebar_install_deps_SUITE.erl
@@ -39,7 +39,7 @@ init_per_testcase(Case, Config) ->
mock_warnings(),
[{expect, Expected},
{warnings, Warnings}
- | setup_project(Case, Config, expand_deps(DepsType, Deps))].
+ | setup_project(Case, Config, rebar_test_utils:expand_deps(DepsType, Deps))].
end_per_testcase(_, Config) ->
meck:unload(),
@@ -110,20 +110,6 @@ deps(circular_skip) ->
[{"C","2"}],
{ok, ["B", {"C","1"}, "D"]}}.
-expand_deps(_, []) -> [];
-expand_deps(git, [{Name, Deps} | Rest]) ->
- Dep = {Name, ".*", {git, "https://example.org/user/"++Name++".git", "master"}},
- [{Dep, expand_deps(git, Deps)} | expand_deps(git, Rest)];
-expand_deps(git, [{Name, Vsn, Deps} | Rest]) ->
- Dep = {Name, Vsn, {git, "https://example.org/user/"++Name++".git", {tag, Vsn}}},
- [{Dep, expand_deps(git, Deps)} | expand_deps(git, Rest)];
-expand_deps(pkg, [{Name, Deps} | Rest]) ->
- Dep = {pkg, Name, "0.0.0", "https://example.org/user/"++Name++".tar.gz"},
- [{Dep, expand_deps(pkg, Deps)} | expand_deps(pkg, Rest)];
-expand_deps(pkg, [{Name, Vsn, Deps} | Rest]) ->
- Dep = {pkg, Name, Vsn, "https://example.org/user/"++Name++".tar.gz"},
- [{Dep, expand_deps(pkg, Deps)} | expand_deps(pkg, Rest)].
-
setup_project(Case, Config0, Deps) ->
DepsType = ?config(deps_type, Config0),
Config = rebar_test_utils:init_rebar_state(
@@ -132,50 +118,16 @@ setup_project(Case, Config0, Deps) ->
),
AppDir = ?config(apps, Config),
rebar_test_utils:create_app(AppDir, "A", "0.0.0", [kernel, stdlib]),
- TopDeps = top_level_deps(Deps),
+ TopDeps = rebar_test_utils:top_level_deps(Deps),
RebarConf = rebar_test_utils:create_config(AppDir, [{deps, TopDeps}]),
case DepsType of
git ->
- mock_git_resource:mock([{deps, flat_deps(Deps)}]);
+ mock_git_resource:mock([{deps, rebar_test_utils:flat_deps(Deps)}]);
pkg ->
- mock_pkg_resource:mock([{pkgdeps, flat_pkgdeps(Deps)}])
+ mock_pkg_resource:mock([{pkgdeps, rebar_test_utils:flat_pkgdeps(Deps)}])
end,
[{rebarconfig, RebarConf} | Config].
-
-flat_deps([]) -> [];
-flat_deps([{{Name,_Vsn,Ref}, Deps} | Rest]) ->
- [{{Name,vsn_from_ref(Ref)}, top_level_deps(Deps)}]
- ++
- flat_deps(Deps)
- ++
- flat_deps(Rest).
-
-vsn_from_ref({git, _, {_, Vsn}}) -> Vsn;
-vsn_from_ref({git, _, Vsn}) -> Vsn.
-
-flat_pkgdeps([]) -> [];
-flat_pkgdeps([{{pkg, Name, Vsn, _Url}, Deps} | Rest]) ->
- [{{iolist_to_binary(Name),iolist_to_binary(Vsn)}, top_level_deps(Deps)}]
- ++
- flat_pkgdeps(Deps)
- ++
- flat_pkgdeps(Rest).
-
-top_level_deps([]) -> [];
-top_level_deps([{{Name, Vsn, Ref}, _} | Deps]) ->
- [{list_to_atom(Name), Vsn, Ref} | top_level_deps(Deps)];
-top_level_deps([{{pkg, Name, Vsn, _URL}, _} | Deps]) ->
- [{list_to_atom(Name), Vsn} | top_level_deps(Deps)].
-
-app_vsn([]) -> [];
-app_vsn([{Source, Deps} | Rest]) ->
- {Name, Vsn} = case Source of
- {N,V,_Ref} -> {N,V};
- {pkg, N, V, _} -> {N,V}
- end,
- [{Name, Vsn}] ++ app_vsn(Deps) ++ app_vsn(Rest).
-
mock_warnings() ->
%% just let it do its thing, we check warnings through
%% the call log.