mirror of
https://github.com/correl/rebar.git
synced 2024-11-27 11:09:55 +00:00
Remove ?FAIL in favor of ?ABORT
This commit is contained in:
parent
c122eeec75
commit
c86c99940d
19 changed files with 43 additions and 39 deletions
|
@ -1,5 +1,5 @@
|
|||
-define(FAIL, throw({error, failed})).
|
||||
|
||||
-define(ABORT, rebar_utils:abort()).
|
||||
-define(ABORT(Str, Args), rebar_utils:abort(Str, Args)).
|
||||
|
||||
-define(CONSOLE(Str, Args), io:format(Str, Args)).
|
||||
|
|
|
@ -90,7 +90,7 @@ compile_abnfc(Source, _Target, Config) ->
|
|||
" https://github.com/nygge/abnfc~n"
|
||||
" and install it into your erlang library dir~n"
|
||||
"===============================================~n~n", []),
|
||||
?FAIL;
|
||||
?ABORT;
|
||||
true ->
|
||||
AbnfcOpts = abnfc_opts(Config),
|
||||
SourceExt = option(source_ext, AbnfcOpts),
|
||||
|
@ -103,6 +103,6 @@ compile_abnfc(Source, _Target, Config) ->
|
|||
Error ->
|
||||
?ERROR("Compiling grammar ~s failed:~n ~p~n",
|
||||
[Source, Error]),
|
||||
?FAIL
|
||||
?ABORT
|
||||
end
|
||||
end.
|
||||
|
|
|
@ -65,7 +65,7 @@ compile_asn1(Source, Target, Config) ->
|
|||
ok
|
||||
end;
|
||||
{error, _Reason} ->
|
||||
?FAIL
|
||||
?ABORT
|
||||
end.
|
||||
|
||||
asn_generated_files(AsnDir, SrcDir, IncDir) ->
|
||||
|
|
|
@ -149,7 +149,7 @@ compile_queue(Pids, Targets) ->
|
|||
|
||||
{fail, Error} ->
|
||||
?DEBUG("Worker compilation failed: ~p\n", [Error]),
|
||||
?FAIL;
|
||||
?ABORT;
|
||||
|
||||
{compiled, Source} ->
|
||||
?CONSOLE("Compiled ~s\n", [Source]),
|
||||
|
@ -166,7 +166,7 @@ compile_queue(Pids, Targets) ->
|
|||
|
||||
{'DOWN', _Mref, _, _Pid, Info} ->
|
||||
?DEBUG("Worker failed: ~p\n", [Info]),
|
||||
?FAIL
|
||||
?ABORT
|
||||
end.
|
||||
|
||||
compile_worker(QueuePid, Config, CompileFn) ->
|
||||
|
|
|
@ -67,7 +67,7 @@ process_commands([], _ParentConfig) ->
|
|||
case erlang:get(operations) of
|
||||
0 ->
|
||||
%% none of the commands had an effect
|
||||
?FAIL;
|
||||
?ABORT;
|
||||
_ ->
|
||||
ok
|
||||
end;
|
||||
|
@ -362,7 +362,7 @@ execute(Command, Modules, Config, ModuleFile, Env) ->
|
|||
apply_hooks(post_hooks, Config, Command, Env),
|
||||
ok;
|
||||
{error, failed} ->
|
||||
?FAIL;
|
||||
?ABORT;
|
||||
{Module, {error, _} = Other} ->
|
||||
?ABORT("~p failed while processing ~s in module ~s: ~s\n",
|
||||
[Command, Dir, Module,
|
||||
|
|
|
@ -83,7 +83,7 @@ clear_log(RawLog) ->
|
|||
ok = file:write_file(RawLog, LogHeader);
|
||||
{error, Reason} ->
|
||||
?ERROR("Could not create log dir - ~p\n", [Reason]),
|
||||
?FAIL
|
||||
?ABORT
|
||||
end.
|
||||
|
||||
%% calling ct with erl does not return non-zero on failure - have to check
|
||||
|
@ -98,12 +98,12 @@ check_log(RawLog) ->
|
|||
MakeFailed ->
|
||||
show_log(RawLog),
|
||||
?ERROR("Building tests failed\n",[]),
|
||||
?FAIL;
|
||||
?ABORT;
|
||||
|
||||
RunFailed ->
|
||||
show_log(RawLog),
|
||||
?ERROR("One or more tests failed\n",[]),
|
||||
?FAIL;
|
||||
?ABORT;
|
||||
|
||||
true ->
|
||||
?CONSOLE("DONE.\n~s\n", [Msg])
|
||||
|
@ -257,7 +257,7 @@ find_suite_path(Suite, TestDir) ->
|
|||
case filelib:is_regular(Path) of
|
||||
false ->
|
||||
?ERROR("Suite ~s not found\n", [Suite]),
|
||||
?FAIL;
|
||||
?ABORT;
|
||||
true ->
|
||||
Path
|
||||
end.
|
||||
|
|
|
@ -123,7 +123,7 @@ setup_env(_Config) ->
|
|||
?CONSOLE("Dependency not available: "
|
||||
"~p-~s (~p)\n", [App, Vsn, Src])
|
||||
end, MissingDeps),
|
||||
?FAIL
|
||||
?ABORT
|
||||
end.
|
||||
|
||||
'get-deps'(Config, _) ->
|
||||
|
|
|
@ -261,7 +261,7 @@ internal_erl_compile(Source, Config, Outdir, ErlOpts) ->
|
|||
{ok, _} ->
|
||||
ok;
|
||||
_ ->
|
||||
?FAIL
|
||||
?ABORT
|
||||
end;
|
||||
false ->
|
||||
skipped
|
||||
|
@ -282,7 +282,7 @@ compile_mib(Source, Target, Config) ->
|
|||
rebar_file_utils:mv(Hrl_filename, "include"),
|
||||
ok;
|
||||
{error, compilation_failed} ->
|
||||
?FAIL
|
||||
?ABORT
|
||||
end.
|
||||
|
||||
-spec compile_xrl(Source::file:filename(), Target::file:filename(),
|
||||
|
@ -306,7 +306,7 @@ compile_xrl_yrl(Source, Target, Opts, Mod) ->
|
|||
{ok, _} ->
|
||||
ok;
|
||||
_X ->
|
||||
?FAIL
|
||||
?ABORT
|
||||
end;
|
||||
false ->
|
||||
skipped
|
||||
|
|
|
@ -120,7 +120,7 @@ compile_dtl(Source, Target, Config) ->
|
|||
" http://code.google.com/p/erlydtl/~n"
|
||||
" and install it into your erlang library dir~n"
|
||||
"===============================================~n~n", []),
|
||||
?FAIL;
|
||||
?ABORT;
|
||||
_ ->
|
||||
case needs_compile(Source, Target, Config) of
|
||||
true ->
|
||||
|
@ -146,7 +146,7 @@ do_compile(Source, Target, Config) ->
|
|||
Reason ->
|
||||
?ERROR("Compiling template ~s failed:~n ~p~n",
|
||||
[Source, Reason]),
|
||||
?FAIL
|
||||
?ABORT
|
||||
end.
|
||||
|
||||
module_name(Target) ->
|
||||
|
|
|
@ -69,12 +69,12 @@ escriptize(Config, AppFile) ->
|
|||
{error, WriteError} ->
|
||||
?ERROR("Failed to write ~p script: ~p\n",
|
||||
[AppName, WriteError]),
|
||||
?FAIL
|
||||
?ABORT
|
||||
end;
|
||||
{error, ZipError} ->
|
||||
?ERROR("Failed to construct ~p escript: ~p\n",
|
||||
[AppName, ZipError]),
|
||||
?FAIL
|
||||
?ABORT
|
||||
end,
|
||||
|
||||
%% Finally, update executable perms for our script
|
||||
|
|
|
@ -329,7 +329,7 @@ cover_init(true, BeamFiles) ->
|
|||
[] ->
|
||||
%% No modules compiled successfully...fail
|
||||
?ERROR("Cover failed to compile any modules; aborting.~n", []),
|
||||
?FAIL;
|
||||
?ABORT;
|
||||
_ ->
|
||||
%% At least one module compiled successfully
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ delete_each([File | Rest]) ->
|
|||
delete_each(Rest);
|
||||
{error, Reason} ->
|
||||
?ERROR("Failed to delete file ~s: ~p\n", [File, Reason]),
|
||||
?FAIL
|
||||
?ABORT
|
||||
end.
|
||||
|
||||
%% ===================================================================
|
||||
|
|
|
@ -57,7 +57,7 @@ compile_lfe(Source, _Target, Config) ->
|
|||
" {git, \"git://github.com/rvirding/lfe\",~n"
|
||||
" {tag, \"v0.6.1\"}}}~n"
|
||||
"~n", []),
|
||||
?FAIL;
|
||||
?ABORT;
|
||||
_ ->
|
||||
Opts = [{i, "include"}, {outdir, "ebin"}, report]
|
||||
++ rebar_config:get_list(Config, erl_opts, []),
|
||||
|
@ -65,6 +65,6 @@ compile_lfe(Source, _Target, Config) ->
|
|||
{ok, _} ->
|
||||
ok;
|
||||
_ ->
|
||||
?FAIL
|
||||
?ABORT
|
||||
end
|
||||
end.
|
||||
|
|
|
@ -80,7 +80,7 @@ compile_neo(Source, Target, Config) ->
|
|||
" https://github.com/seancribbs/neotoma~n"
|
||||
" and install it into your erlang library dir~n"
|
||||
"===============================================~n~n", []),
|
||||
?FAIL;
|
||||
?ABORT;
|
||||
_ ->
|
||||
case needs_compile(Source, Target, Config) of
|
||||
true ->
|
||||
|
@ -104,7 +104,7 @@ do_compile(Source, _Target, Config) ->
|
|||
Reason ->
|
||||
?ERROR("Compiling peg ~s failed:~n ~p~n",
|
||||
[Source, Reason]),
|
||||
?FAIL
|
||||
?ABORT
|
||||
end.
|
||||
|
||||
needs_compile(Source, Target, Config) ->
|
||||
|
|
|
@ -146,12 +146,12 @@ validate_name(AppName, File) ->
|
|||
false ->
|
||||
?ERROR("Invalid ~s: name of application (~p) "
|
||||
"must match filename.\n", [File, AppName]),
|
||||
?FAIL
|
||||
?ABORT
|
||||
end.
|
||||
|
||||
validate_modules(AppName, undefined) ->
|
||||
?ERROR("Missing modules declaration in ~p.app~n", [AppName]),
|
||||
?FAIL;
|
||||
?ABORT;
|
||||
|
||||
validate_modules(AppName, Mods) ->
|
||||
%% Construct two sets -- one for the actual .beam files in ebin/
|
||||
|
@ -169,7 +169,7 @@ validate_modules(AppName, Mods) ->
|
|||
M <- MissingBeams]),
|
||||
?ERROR("One or more modules listed in ~p.app are not "
|
||||
"present in ebin/*.beam:\n~s", [AppName, Msg1]),
|
||||
?FAIL
|
||||
?ABORT
|
||||
end,
|
||||
|
||||
%% Identify .beam files NOT list in the .app, but present in ebin/
|
||||
|
@ -181,7 +181,7 @@ validate_modules(AppName, Mods) ->
|
|||
M <- MissingMods]),
|
||||
?ERROR("One or more .beam files exist that are not "
|
||||
"listed in ~p.app:\n~s", [AppName, Msg2]),
|
||||
?FAIL
|
||||
?ABORT
|
||||
end.
|
||||
|
||||
ebin_modules() ->
|
||||
|
|
|
@ -53,7 +53,7 @@ compile(_Config, _AppFile) ->
|
|||
false ->
|
||||
?ERROR("Protobuffs library not present in code path!\n",
|
||||
[]),
|
||||
?FAIL
|
||||
?ABORT
|
||||
end
|
||||
end.
|
||||
|
||||
|
@ -115,7 +115,7 @@ compile_each([{Proto, Beam, Hrl} | Rest]) ->
|
|||
Other ->
|
||||
?ERROR("Protobuff compile of ~s failed: ~p\n",
|
||||
[Proto, Other]),
|
||||
?FAIL
|
||||
?ABORT
|
||||
end;
|
||||
false ->
|
||||
ok
|
||||
|
|
|
@ -58,10 +58,10 @@ generate(Config, ReltoolFile) ->
|
|||
ok ->
|
||||
ok;
|
||||
{error, failed} ->
|
||||
?FAIL;
|
||||
?ABORT;
|
||||
Other2 ->
|
||||
?ERROR("Unexpected error: ~p\n", [Other2]),
|
||||
?FAIL
|
||||
?ABORT
|
||||
end.
|
||||
|
||||
overlay(_Config, ReltoolFile) ->
|
||||
|
@ -235,12 +235,12 @@ mk_target_dir(TargetDir) ->
|
|||
_ ->
|
||||
?ERROR("Release target directory ~p already exists!\n",
|
||||
[TargetDir]),
|
||||
?FAIL
|
||||
?ABORT
|
||||
end;
|
||||
{error, Reason} ->
|
||||
?ERROR("Failed to make target dir ~p: ~s\n",
|
||||
[TargetDir, file:format_error(Reason)]),
|
||||
?FAIL
|
||||
?ABORT
|
||||
end.
|
||||
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
ensure_dir/1,
|
||||
beam_to_mod/2, beams/1,
|
||||
erl_to_mod/1,
|
||||
abort/2,
|
||||
abort/0, abort/2,
|
||||
escript_foldl/3,
|
||||
find_executable/1,
|
||||
prop_check/3,
|
||||
|
@ -137,10 +137,14 @@ ensure_dir(Path) ->
|
|||
Error
|
||||
end.
|
||||
|
||||
-spec abort() -> no_return().
|
||||
abort() ->
|
||||
delayed_halt(1).
|
||||
|
||||
-spec abort(string(), [term()]) -> no_return().
|
||||
abort(String, Args) ->
|
||||
?ERROR(String, Args),
|
||||
delayed_halt(1).
|
||||
abort().
|
||||
|
||||
%% TODO: Rename emulate_escript_foldl to escript_foldl and remove
|
||||
%% this function when the time is right. escript:foldl/3 was an
|
||||
|
|
|
@ -90,7 +90,7 @@ xref(Config, _) ->
|
|||
|
||||
case lists:member(false, [ExportsNoWarn, UndefNoWarn, QueryNoWarn]) of
|
||||
true ->
|
||||
?FAIL;
|
||||
?ABORT;
|
||||
false ->
|
||||
ok
|
||||
end.
|
||||
|
|
Loading…
Reference in a new issue