Remove ?FAIL in favor of ?ABORT

This commit is contained in:
Dave Smith 2012-06-04 10:36:28 -06:00
parent c122eeec75
commit c86c99940d
19 changed files with 43 additions and 39 deletions

View file

@ -1,5 +1,5 @@
-define(FAIL, throw({error, failed})).
-define(ABORT, rebar_utils:abort()).
-define(ABORT(Str, Args), rebar_utils:abort(Str, Args)). -define(ABORT(Str, Args), rebar_utils:abort(Str, Args)).
-define(CONSOLE(Str, Args), io:format(Str, Args)). -define(CONSOLE(Str, Args), io:format(Str, Args)).

View file

@ -90,7 +90,7 @@ compile_abnfc(Source, _Target, Config) ->
" https://github.com/nygge/abnfc~n" " https://github.com/nygge/abnfc~n"
" and install it into your erlang library dir~n" " and install it into your erlang library dir~n"
"===============================================~n~n", []), "===============================================~n~n", []),
?FAIL; ?ABORT;
true -> true ->
AbnfcOpts = abnfc_opts(Config), AbnfcOpts = abnfc_opts(Config),
SourceExt = option(source_ext, AbnfcOpts), SourceExt = option(source_ext, AbnfcOpts),
@ -103,6 +103,6 @@ compile_abnfc(Source, _Target, Config) ->
Error -> Error ->
?ERROR("Compiling grammar ~s failed:~n ~p~n", ?ERROR("Compiling grammar ~s failed:~n ~p~n",
[Source, Error]), [Source, Error]),
?FAIL ?ABORT
end end
end. end.

View file

@ -65,7 +65,7 @@ compile_asn1(Source, Target, Config) ->
ok ok
end; end;
{error, _Reason} -> {error, _Reason} ->
?FAIL ?ABORT
end. end.
asn_generated_files(AsnDir, SrcDir, IncDir) -> asn_generated_files(AsnDir, SrcDir, IncDir) ->

View file

@ -149,7 +149,7 @@ compile_queue(Pids, Targets) ->
{fail, Error} -> {fail, Error} ->
?DEBUG("Worker compilation failed: ~p\n", [Error]), ?DEBUG("Worker compilation failed: ~p\n", [Error]),
?FAIL; ?ABORT;
{compiled, Source} -> {compiled, Source} ->
?CONSOLE("Compiled ~s\n", [Source]), ?CONSOLE("Compiled ~s\n", [Source]),
@ -166,7 +166,7 @@ compile_queue(Pids, Targets) ->
{'DOWN', _Mref, _, _Pid, Info} -> {'DOWN', _Mref, _, _Pid, Info} ->
?DEBUG("Worker failed: ~p\n", [Info]), ?DEBUG("Worker failed: ~p\n", [Info]),
?FAIL ?ABORT
end. end.
compile_worker(QueuePid, Config, CompileFn) -> compile_worker(QueuePid, Config, CompileFn) ->

View file

@ -67,7 +67,7 @@ process_commands([], _ParentConfig) ->
case erlang:get(operations) of case erlang:get(operations) of
0 -> 0 ->
%% none of the commands had an effect %% none of the commands had an effect
?FAIL; ?ABORT;
_ -> _ ->
ok ok
end; end;
@ -362,7 +362,7 @@ execute(Command, Modules, Config, ModuleFile, Env) ->
apply_hooks(post_hooks, Config, Command, Env), apply_hooks(post_hooks, Config, Command, Env),
ok; ok;
{error, failed} -> {error, failed} ->
?FAIL; ?ABORT;
{Module, {error, _} = Other} -> {Module, {error, _} = Other} ->
?ABORT("~p failed while processing ~s in module ~s: ~s\n", ?ABORT("~p failed while processing ~s in module ~s: ~s\n",
[Command, Dir, Module, [Command, Dir, Module,

View file

@ -83,7 +83,7 @@ clear_log(RawLog) ->
ok = file:write_file(RawLog, LogHeader); ok = file:write_file(RawLog, LogHeader);
{error, Reason} -> {error, Reason} ->
?ERROR("Could not create log dir - ~p\n", [Reason]), ?ERROR("Could not create log dir - ~p\n", [Reason]),
?FAIL ?ABORT
end. end.
%% calling ct with erl does not return non-zero on failure - have to check %% calling ct with erl does not return non-zero on failure - have to check
@ -98,12 +98,12 @@ check_log(RawLog) ->
MakeFailed -> MakeFailed ->
show_log(RawLog), show_log(RawLog),
?ERROR("Building tests failed\n",[]), ?ERROR("Building tests failed\n",[]),
?FAIL; ?ABORT;
RunFailed -> RunFailed ->
show_log(RawLog), show_log(RawLog),
?ERROR("One or more tests failed\n",[]), ?ERROR("One or more tests failed\n",[]),
?FAIL; ?ABORT;
true -> true ->
?CONSOLE("DONE.\n~s\n", [Msg]) ?CONSOLE("DONE.\n~s\n", [Msg])
@ -257,7 +257,7 @@ find_suite_path(Suite, TestDir) ->
case filelib:is_regular(Path) of case filelib:is_regular(Path) of
false -> false ->
?ERROR("Suite ~s not found\n", [Suite]), ?ERROR("Suite ~s not found\n", [Suite]),
?FAIL; ?ABORT;
true -> true ->
Path Path
end. end.

View file

@ -123,7 +123,7 @@ setup_env(_Config) ->
?CONSOLE("Dependency not available: " ?CONSOLE("Dependency not available: "
"~p-~s (~p)\n", [App, Vsn, Src]) "~p-~s (~p)\n", [App, Vsn, Src])
end, MissingDeps), end, MissingDeps),
?FAIL ?ABORT
end. end.
'get-deps'(Config, _) -> 'get-deps'(Config, _) ->

View file

@ -261,7 +261,7 @@ internal_erl_compile(Source, Config, Outdir, ErlOpts) ->
{ok, _} -> {ok, _} ->
ok; ok;
_ -> _ ->
?FAIL ?ABORT
end; end;
false -> false ->
skipped skipped
@ -282,7 +282,7 @@ compile_mib(Source, Target, Config) ->
rebar_file_utils:mv(Hrl_filename, "include"), rebar_file_utils:mv(Hrl_filename, "include"),
ok; ok;
{error, compilation_failed} -> {error, compilation_failed} ->
?FAIL ?ABORT
end. end.
-spec compile_xrl(Source::file:filename(), Target::file:filename(), -spec compile_xrl(Source::file:filename(), Target::file:filename(),
@ -306,7 +306,7 @@ compile_xrl_yrl(Source, Target, Opts, Mod) ->
{ok, _} -> {ok, _} ->
ok; ok;
_X -> _X ->
?FAIL ?ABORT
end; end;
false -> false ->
skipped skipped

View file

@ -120,7 +120,7 @@ compile_dtl(Source, Target, Config) ->
" http://code.google.com/p/erlydtl/~n" " http://code.google.com/p/erlydtl/~n"
" and install it into your erlang library dir~n" " and install it into your erlang library dir~n"
"===============================================~n~n", []), "===============================================~n~n", []),
?FAIL; ?ABORT;
_ -> _ ->
case needs_compile(Source, Target, Config) of case needs_compile(Source, Target, Config) of
true -> true ->
@ -146,7 +146,7 @@ do_compile(Source, Target, Config) ->
Reason -> Reason ->
?ERROR("Compiling template ~s failed:~n ~p~n", ?ERROR("Compiling template ~s failed:~n ~p~n",
[Source, Reason]), [Source, Reason]),
?FAIL ?ABORT
end. end.
module_name(Target) -> module_name(Target) ->

View file

@ -69,12 +69,12 @@ escriptize(Config, AppFile) ->
{error, WriteError} -> {error, WriteError} ->
?ERROR("Failed to write ~p script: ~p\n", ?ERROR("Failed to write ~p script: ~p\n",
[AppName, WriteError]), [AppName, WriteError]),
?FAIL ?ABORT
end; end;
{error, ZipError} -> {error, ZipError} ->
?ERROR("Failed to construct ~p escript: ~p\n", ?ERROR("Failed to construct ~p escript: ~p\n",
[AppName, ZipError]), [AppName, ZipError]),
?FAIL ?ABORT
end, end,
%% Finally, update executable perms for our script %% Finally, update executable perms for our script

View file

@ -329,7 +329,7 @@ cover_init(true, BeamFiles) ->
[] -> [] ->
%% No modules compiled successfully...fail %% No modules compiled successfully...fail
?ERROR("Cover failed to compile any modules; aborting.~n", []), ?ERROR("Cover failed to compile any modules; aborting.~n", []),
?FAIL; ?ABORT;
_ -> _ ->
%% At least one module compiled successfully %% At least one module compiled successfully

View file

@ -106,7 +106,7 @@ delete_each([File | Rest]) ->
delete_each(Rest); delete_each(Rest);
{error, Reason} -> {error, Reason} ->
?ERROR("Failed to delete file ~s: ~p\n", [File, Reason]), ?ERROR("Failed to delete file ~s: ~p\n", [File, Reason]),
?FAIL ?ABORT
end. end.
%% =================================================================== %% ===================================================================

View file

@ -57,7 +57,7 @@ compile_lfe(Source, _Target, Config) ->
" {git, \"git://github.com/rvirding/lfe\",~n" " {git, \"git://github.com/rvirding/lfe\",~n"
" {tag, \"v0.6.1\"}}}~n" " {tag, \"v0.6.1\"}}}~n"
"~n", []), "~n", []),
?FAIL; ?ABORT;
_ -> _ ->
Opts = [{i, "include"}, {outdir, "ebin"}, report] Opts = [{i, "include"}, {outdir, "ebin"}, report]
++ rebar_config:get_list(Config, erl_opts, []), ++ rebar_config:get_list(Config, erl_opts, []),
@ -65,6 +65,6 @@ compile_lfe(Source, _Target, Config) ->
{ok, _} -> {ok, _} ->
ok; ok;
_ -> _ ->
?FAIL ?ABORT
end end
end. end.

View file

@ -80,7 +80,7 @@ compile_neo(Source, Target, Config) ->
" https://github.com/seancribbs/neotoma~n" " https://github.com/seancribbs/neotoma~n"
" and install it into your erlang library dir~n" " and install it into your erlang library dir~n"
"===============================================~n~n", []), "===============================================~n~n", []),
?FAIL; ?ABORT;
_ -> _ ->
case needs_compile(Source, Target, Config) of case needs_compile(Source, Target, Config) of
true -> true ->
@ -104,7 +104,7 @@ do_compile(Source, _Target, Config) ->
Reason -> Reason ->
?ERROR("Compiling peg ~s failed:~n ~p~n", ?ERROR("Compiling peg ~s failed:~n ~p~n",
[Source, Reason]), [Source, Reason]),
?FAIL ?ABORT
end. end.
needs_compile(Source, Target, Config) -> needs_compile(Source, Target, Config) ->

View file

@ -146,12 +146,12 @@ validate_name(AppName, File) ->
false -> false ->
?ERROR("Invalid ~s: name of application (~p) " ?ERROR("Invalid ~s: name of application (~p) "
"must match filename.\n", [File, AppName]), "must match filename.\n", [File, AppName]),
?FAIL ?ABORT
end. end.
validate_modules(AppName, undefined) -> validate_modules(AppName, undefined) ->
?ERROR("Missing modules declaration in ~p.app~n", [AppName]), ?ERROR("Missing modules declaration in ~p.app~n", [AppName]),
?FAIL; ?ABORT;
validate_modules(AppName, Mods) -> validate_modules(AppName, Mods) ->
%% Construct two sets -- one for the actual .beam files in ebin/ %% Construct two sets -- one for the actual .beam files in ebin/
@ -169,7 +169,7 @@ validate_modules(AppName, Mods) ->
M <- MissingBeams]), M <- MissingBeams]),
?ERROR("One or more modules listed in ~p.app are not " ?ERROR("One or more modules listed in ~p.app are not "
"present in ebin/*.beam:\n~s", [AppName, Msg1]), "present in ebin/*.beam:\n~s", [AppName, Msg1]),
?FAIL ?ABORT
end, end,
%% Identify .beam files NOT list in the .app, but present in ebin/ %% Identify .beam files NOT list in the .app, but present in ebin/
@ -181,7 +181,7 @@ validate_modules(AppName, Mods) ->
M <- MissingMods]), M <- MissingMods]),
?ERROR("One or more .beam files exist that are not " ?ERROR("One or more .beam files exist that are not "
"listed in ~p.app:\n~s", [AppName, Msg2]), "listed in ~p.app:\n~s", [AppName, Msg2]),
?FAIL ?ABORT
end. end.
ebin_modules() -> ebin_modules() ->

View file

@ -53,7 +53,7 @@ compile(_Config, _AppFile) ->
false -> false ->
?ERROR("Protobuffs library not present in code path!\n", ?ERROR("Protobuffs library not present in code path!\n",
[]), []),
?FAIL ?ABORT
end end
end. end.
@ -115,7 +115,7 @@ compile_each([{Proto, Beam, Hrl} | Rest]) ->
Other -> Other ->
?ERROR("Protobuff compile of ~s failed: ~p\n", ?ERROR("Protobuff compile of ~s failed: ~p\n",
[Proto, Other]), [Proto, Other]),
?FAIL ?ABORT
end; end;
false -> false ->
ok ok

View file

@ -58,10 +58,10 @@ generate(Config, ReltoolFile) ->
ok -> ok ->
ok; ok;
{error, failed} -> {error, failed} ->
?FAIL; ?ABORT;
Other2 -> Other2 ->
?ERROR("Unexpected error: ~p\n", [Other2]), ?ERROR("Unexpected error: ~p\n", [Other2]),
?FAIL ?ABORT
end. end.
overlay(_Config, ReltoolFile) -> overlay(_Config, ReltoolFile) ->
@ -235,12 +235,12 @@ mk_target_dir(TargetDir) ->
_ -> _ ->
?ERROR("Release target directory ~p already exists!\n", ?ERROR("Release target directory ~p already exists!\n",
[TargetDir]), [TargetDir]),
?FAIL ?ABORT
end; end;
{error, Reason} -> {error, Reason} ->
?ERROR("Failed to make target dir ~p: ~s\n", ?ERROR("Failed to make target dir ~p: ~s\n",
[TargetDir, file:format_error(Reason)]), [TargetDir, file:format_error(Reason)]),
?FAIL ?ABORT
end. end.

View file

@ -37,7 +37,7 @@
ensure_dir/1, ensure_dir/1,
beam_to_mod/2, beams/1, beam_to_mod/2, beams/1,
erl_to_mod/1, erl_to_mod/1,
abort/2, abort/0, abort/2,
escript_foldl/3, escript_foldl/3,
find_executable/1, find_executable/1,
prop_check/3, prop_check/3,
@ -137,10 +137,14 @@ ensure_dir(Path) ->
Error Error
end. end.
-spec abort() -> no_return().
abort() ->
delayed_halt(1).
-spec abort(string(), [term()]) -> no_return(). -spec abort(string(), [term()]) -> no_return().
abort(String, Args) -> abort(String, Args) ->
?ERROR(String, Args), ?ERROR(String, Args),
delayed_halt(1). abort().
%% TODO: Rename emulate_escript_foldl to escript_foldl and remove %% TODO: Rename emulate_escript_foldl to escript_foldl and remove
%% this function when the time is right. escript:foldl/3 was an %% this function when the time is right. escript:foldl/3 was an

View file

@ -90,7 +90,7 @@ xref(Config, _) ->
case lists:member(false, [ExportsNoWarn, UndefNoWarn, QueryNoWarn]) of case lists:member(false, [ExportsNoWarn, UndefNoWarn, QueryNoWarn]) of
true -> true ->
?FAIL; ?ABORT;
false -> false ->
ok ok
end. end.