Report warnings as errors if -Werror is enabled

This commit is contained in:
Tuncer Ayaz 2012-06-01 01:17:49 +02:00
parent dff60918cb
commit 658f4847a2
2 changed files with 11 additions and 4 deletions

View file

@ -29,7 +29,7 @@
-include("rebar.hrl"). -include("rebar.hrl").
-export([run/4, run/7, run/8, -export([run/4, run/7, run/8,
format_errors/2, format_warnings/2]). format_errors/2, format_warnings/2, format_warnings/3]).
%% =================================================================== %% ===================================================================
@ -84,7 +84,14 @@ format_errors(Source, Errors) ->
format_errors(Source, "", Errors). format_errors(Source, "", Errors).
format_warnings(Source, Warnings) -> format_warnings(Source, Warnings) ->
format_errors(Source, "Warning: ", Warnings). format_warnings(Source, Warnings, []).
format_warnings(Source, Warnings, Opts) ->
Prefix = case lists:member(warnings_as_errors, Opts) of
true -> "";
false -> "Warning: "
end,
format_errors(Source, Prefix, Warnings).
%% =================================================================== %% ===================================================================
%% Internal functions %% Internal functions

View file

@ -265,7 +265,7 @@ internal_erl_compile(Source, Config, Outdir, ErlOpts) ->
{ok, rebar_base_compiler:format_warnings(Source, Ws)}; {ok, rebar_base_compiler:format_warnings(Source, Ws)};
{error, Es, Ws} -> {error, Es, Ws} ->
{error, rebar_base_compiler:format_errors(Source, Es), {error, rebar_base_compiler:format_errors(Source, Es),
rebar_base_compiler:format_warnings(Source, Ws)} rebar_base_compiler:format_warnings(Source, Ws, Opts)}
end; end;
false -> false ->
skipped skipped
@ -313,7 +313,7 @@ compile_xrl_yrl(Source, Target, Opts, Mod) ->
{ok, rebar_base_compiler:format_warnings(Source, Ws)}; {ok, rebar_base_compiler:format_warnings(Source, Ws)};
{error, Es, Ws} -> {error, Es, Ws} ->
{error, rebar_base_compiler:format_errors(Source, Es), {error, rebar_base_compiler:format_errors(Source, Es),
rebar_base_compiler:format_warnings(Source, Ws)} rebar_base_compiler:format_warnings(Source, Ws, Opts)}
end; end;
false -> false ->
skipped skipped