mirror of
https://github.com/correl/rebar.git
synced 2024-12-24 11:50:52 +00:00
Merge pull request #252 from tuncer/file_utils-errors
file_utils: properly report errors (fix #95)
This commit is contained in:
commit
837df64087
3 changed files with 8 additions and 7 deletions
|
@ -46,7 +46,7 @@ rm_rf(Target) ->
|
|||
{unix, _} ->
|
||||
EscTarget = escape_spaces(Target),
|
||||
{ok, []} = rebar_utils:sh(?FMT("rm -rf ~s", [EscTarget]),
|
||||
[{use_stdout, false}, return_on_error]),
|
||||
[{use_stdout, false}, abort_on_error]),
|
||||
ok;
|
||||
{win32, _} ->
|
||||
Filelist = filelib:wildcard(Target),
|
||||
|
@ -67,7 +67,7 @@ cp_r(Sources, Dest) ->
|
|||
SourceStr = string:join(EscSources, " "),
|
||||
{ok, []} = rebar_utils:sh(?FMT("cp -R ~s \"~s\"",
|
||||
[SourceStr, Dest]),
|
||||
[{use_stdout, false}, return_on_error]),
|
||||
[{use_stdout, false}, abort_on_error]),
|
||||
ok;
|
||||
{win32, _} ->
|
||||
lists:foreach(fun(Src) -> ok = cp_r_win32(Src,Dest) end, Sources),
|
||||
|
@ -81,7 +81,7 @@ mv(Source, Dest) ->
|
|||
EscSource = escape_spaces(Source),
|
||||
EscDest = escape_spaces(Dest),
|
||||
{ok, []} = rebar_utils:sh(?FMT("mv ~s ~s", [EscSource, EscDest]),
|
||||
[{use_stdout, false}, return_on_error]),
|
||||
[{use_stdout, false}, abort_on_error]),
|
||||
ok;
|
||||
{win32, _} ->
|
||||
{ok, R} = rebar_utils:sh(
|
||||
|
|
|
@ -398,8 +398,9 @@ log_msg_and_abort(Message) ->
|
|||
|
||||
-spec log_and_abort(string(), {integer(), string()}) -> no_return().
|
||||
log_and_abort(Command, {Rc, Output}) ->
|
||||
?ABORT("~s failed with error: ~w and output:~n~s~n",
|
||||
[Command, Rc, Output]).
|
||||
?ABORT("sh(~s)~n"
|
||||
"failed with return code ~w and the following output:~n"
|
||||
"~s~n", [Command, Rc, Output]).
|
||||
|
||||
sh_loop(Port, Fun, Acc) ->
|
||||
receive
|
||||
|
|
|
@ -191,7 +191,7 @@ cp_r_overwrite_file_fail_test_() ->
|
|||
filename:join([?TMP_DIR,"dest","file1"]),0)
|
||||
end,
|
||||
fun teardown/1,
|
||||
[?_assertError({badmatch,_},
|
||||
[?_assertThrow(rebar_abort,
|
||||
rebar_file_utils:cp_r(
|
||||
[filename:join([?TMP_DIR,"source","file1"])],
|
||||
filename:join([?TMP_DIR,"dest"])))]}.
|
||||
|
@ -210,7 +210,7 @@ cp_r_overwrite_dir_fail_test_() ->
|
|||
filename:join([?TMP_DIR,"dest","source","file1"]),0)
|
||||
end,
|
||||
fun teardown/1,
|
||||
[?_assertError({badmatch,_},
|
||||
[?_assertThrow(rebar_abort,
|
||||
rebar_file_utils:cp_r(
|
||||
[filename:join([?TMP_DIR,"source"])],
|
||||
filename:join([?TMP_DIR,"dest"])))]}.
|
||||
|
|
Loading…
Reference in a new issue