diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2014-12-06 23:53:11 +0000 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2014-12-06 23:53:11 +0000 |
commit | be39ab9e7bd1553132def2a1e89f1ce38f6f2fcc (patch) | |
tree | 95feb148cd7c33f46b15ec7fa60edd02ae46cfa0 | |
parent | 63003c3986ca20e2f733e79453315fa0b7076bd9 (diff) |
Handle cycle errors in provider
-rw-r--r-- | src/rebar_prv_install_deps.erl | 8 | ||||
-rw-r--r-- | test/rebar_deps_SUITE.erl | 4 |
2 files changed, 10 insertions, 2 deletions
diff --git a/src/rebar_prv_install_deps.erl b/src/rebar_prv_install_deps.erl index 461baa5..1be094c 100644 --- a/src/rebar_prv_install_deps.erl +++ b/src/rebar_prv_install_deps.erl @@ -81,6 +81,8 @@ do(State) -> {ok, rebar_state:deps_to_build(State1, lists:dropwhile(fun rebar_app_info:valid/1 , Sort -- ProjectApps))}; + {error, {cycles, Cycles}} -> + {error, {?MODULE, {cycles, Cycles}}}; {error, Error} -> {error, Error} end @@ -91,6 +93,12 @@ do(State) -> end. -spec format_error(any()) -> iolist(). +format_error({cycles, Cycles}) -> + Prints = [["applications: ", + [io_lib:format("~s ", [Dep]) || Dep <- Cycle], + "depend on each other~n"] + || Cycle <- Cycles], + ["Dependency cycle(s) detected:~n", Prints]; format_error(Reason) -> io_lib:format("~p", [Reason]). diff --git a/test/rebar_deps_SUITE.erl b/test/rebar_deps_SUITE.erl index a98f690..656c3b5 100644 --- a/test/rebar_deps_SUITE.erl +++ b/test/rebar_deps_SUITE.erl @@ -47,11 +47,11 @@ deps(pick_earliest) -> deps(circular1) -> {[{"B", [{"A", []}]}, % A is the top-level app {"C", []}], - {error, {cycles, [[<<"A">>,<<"B">>]]}}}; % circular dep + {error, {rebar_prv_install_deps, {cycles, [[<<"A">>,<<"B">>]]}}}}; deps(circular2) -> {[{"B", [{"C", [{"B", []}]}]}, {"C", []}], - {error, {cycles, [[<<"B">>,<<"C">>]]}}}. % circular dep + {error, {rebar_prv_install_deps, {cycles, [[<<"B">>,<<"C">>]]}}}}. end_per_testcase(_, Config) -> mock_git_resource:unmock(), |