summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/rebar_fetch.erl7
-rw-r--r--src/rebar_prv_test_deps.erl27
-rw-r--r--src/rebar_utils.erl17
3 files changed, 28 insertions, 23 deletions
diff --git a/src/rebar_fetch.erl b/src/rebar_fetch.erl
index a7ae446..987477f 100644
--- a/src/rebar_fetch.erl
+++ b/src/rebar_fetch.erl
@@ -59,7 +59,12 @@ needs_update(AppDir, Source) ->
{error, _}=Error ->
Error;
Module ->
- Module:needs_update(AppDir, Source)
+ try
+ Module:needs_update(AppDir, Source)
+ catch
+ _:_ ->
+ true
+ end
end.
get_resource_type({Type, Location, _}) ->
diff --git a/src/rebar_prv_test_deps.erl b/src/rebar_prv_test_deps.erl
index 081b210..a51f635 100644
--- a/src/rebar_prv_test_deps.erl
+++ b/src/rebar_prv_test_deps.erl
@@ -9,7 +9,9 @@
-include("rebar.hrl").
-define(PROVIDER, test_deps).
--define(DEPS, [install_deps]).
+-define(DEPS, []).
+
+-define(DEFAULT_TEST_DEPS_DIR, "_tdeps").
%% ===================================================================
%% Public API
@@ -17,13 +19,11 @@
-spec init(rebar_state:t()) -> {ok, rebar_state:t()}.
init(State) ->
- Providers = rebar_state:providers(State),
- CompileProvider = providers:get_provider(compile, Providers),
State1 = rebar_state:add_provider(State, providers:create([{name, ?PROVIDER},
{module, ?MODULE},
{bare, true},
{deps, ?DEPS},
- {hooks, {[], [CompileProvider]}},
+ {hooks, {[], []}},
{example, undefined},
{short_desc, "Install dependencies needed only for testing."},
{desc, ""},
@@ -37,19 +37,18 @@ do(State) ->
Names = [ec_cnv:to_binary(element(1, Dep)) || Dep <- TestDeps],
ProjectApps1 = [rebar_app_info:deps(A, Names) || A <- ProjectApps],
- {ok, State1} = rebar_prv_install_deps:handle_deps(State, TestDeps),
- AllDeps = rebar_state:get(State1, all_deps, []),
+ TestDepsDir = rebar_state:get(State, test_deps_dir, ?DEFAULT_TEST_DEPS_DIR),
+ DepsDir = rebar_state:get(State, deps_dir, ?DEFAULT_DEPS_DIR),
+ State1 = rebar_state:set(State, deps_dir, TestDepsDir),
+ {ok, State2} = rebar_prv_install_deps:handle_deps(State1, TestDeps),
+ AllDeps = rebar_state:get(State2, all_deps, []),
+ State3 = rebar_state:set(State2, deps_dir, DepsDir),
case rebar_topo:sort_apps(ProjectApps1++AllDeps) of
{ok, Sort} ->
- _ToBuild = lists:dropwhile(fun rebar_app_info:valid/1, Sort),
- %% lists:foreach(fun(AppInfo) ->
- %% AppDir = rebar_app_info:dir(AppInfo),
- %% C = rebar_config:consult(AppDir),
- %% S = rebar_state:new(State1, C, AppDir),
- %% rebar_prv_compile:build(S, AppInfo)
- %% end, ToBuild),
- {ok, State1};
+ ToBuild = lists:dropwhile(fun rebar_app_info:valid/1, Sort -- ProjectApps1),
+ State4 = rebar_state:set(State3, deps_to_build, ToBuild),
+ {ok, State4};
{error, Error} ->
{error, Error}
end.
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index ae1d126..c39bbfa 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -135,7 +135,7 @@ sh(Command0, Options0) ->
?DEBUG("sh info:\n\tcwd: ~p\n\tcmd: ~s\n", [get_cwd(), Command0]),
?DEBUG("\topts: ~p\n", [Options0]),
- DefaultOptions = [{use_stdout, false}, abort_on_error],
+ DefaultOptions = [{use_stdout, false}, debug_and_abort_on_error],
Options = [expand_sh_flag(V)
|| V <- proplists:compact(Options0 ++ DefaultOptions)],
@@ -359,9 +359,9 @@ expand_sh_flag(return_on_error) ->
expand_sh_flag({abort_on_error, Message}) ->
{error_handler,
log_msg_and_abort(Message)};
-expand_sh_flag(abort_on_error) ->
+expand_sh_flag(debug_and_abort_on_error) ->
{error_handler,
- fun log_and_abort/2};
+ fun debug_and_abort/2};
expand_sh_flag(use_stdout) ->
{output_handler,
fun(Line, Acc) ->
@@ -385,11 +385,12 @@ log_msg_and_abort(Message) ->
?ABORT(Message, [])
end.
--spec log_and_abort(string(), {integer(), string()}) -> no_return().
-log_and_abort(Command, {Rc, Output}) ->
- ?ABORT("sh(~s)~n"
- "failed with return code ~w and the following output:~n"
- "~s~n", [Command, Rc, Output]).
+-spec debug_and_abort(string(), {integer(), string()}) -> no_return().
+debug_and_abort(Command, {Rc, Output}) ->
+ ?DEBUG("sh(~s)~n"
+ "failed with return code ~w and the following output:~n"
+ "~s~n", [Command, Rc, Output]),
+ throw(rebar_abort).
sh_loop(Port, Fun, Acc) ->
receive