aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/test/erl_lint_SUITE.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2015-12-03 12:28:23 +0100
committerBjörn Gustavsson <[email protected]>2015-12-03 13:05:22 +0100
commit78b3b26ece408ca90e3e78873e9a0212777973fe (patch)
tree6650cd93b07cd8b8dccd5e8d17a615c913974645 /lib/stdlib/test/erl_lint_SUITE.erl
parent2124579786928996cfd81e58df4615247af5cd79 (diff)
downloadotp-78b3b26ece408ca90e3e78873e9a0212777973fe.tar.gz
otp-78b3b26ece408ca90e3e78873e9a0212777973fe.tar.bz2
otp-78b3b26ece408ca90e3e78873e9a0212777973fe.zip
erl_lint_SUITE: Add smoke test of format_error/1
The test suite depended on the compiler to call erl_lint:format_error/1 to ensure that format_error/1 was covered. Unfortunately, though, if format_error/1 crashed the compiler would catch the exception so that the test suite would not notice it. Add a smoke test of format_error/1 that will crash if there is any problem with erl_lint:format_error/1.
Diffstat (limited to 'lib/stdlib/test/erl_lint_SUITE.erl')
-rw-r--r--lib/stdlib/test/erl_lint_SUITE.erl27
1 files changed, 20 insertions, 7 deletions
diff --git a/lib/stdlib/test/erl_lint_SUITE.erl b/lib/stdlib/test/erl_lint_SUITE.erl
index 0424e2b967..e6c1f4a87a 100644
--- a/lib/stdlib/test/erl_lint_SUITE.erl
+++ b/lib/stdlib/test/erl_lint_SUITE.erl
@@ -3920,22 +3920,35 @@ run_test2(Conf, Test, Warnings0) ->
%% is no reason to produce an output file since we are only
%% interested in the errors and warnings.
- %% Print warnings, call erl_lint:format_error/1.
+ %% Print warnings, call erl_lint:format_error/1. (But note that
+ %% the compiler will ignore failing calls to erl_lint:format_error/1.)
compile:file(File, [binary,report|Opts]),
case compile:file(File, [binary|Opts]) of
- {ok, _M, Code, Ws} when is_binary(Code) -> warnings(File, Ws);
- {error, [{File,Es}], []} -> {errors, Es, []};
- {error, [{File,Es}], [{File,Ws}]} -> {error, Es, Ws};
- {error, [{File,Es1},{File,Es2}], []} -> {errors2, Es1, Es2}
+ {ok, _M, Code, Ws} when is_binary(Code) ->
+ warnings(File, Ws);
+ {error, [{File,Es}], []} ->
+ {errors, call_format_error(Es), []};
+ {error, [{File,Es}], [{File,Ws}]} ->
+ {error, call_format_error(Es), call_format_error(Ws)};
+ {error, [{File,Es1},{File,Es2}], []} ->
+ {errors2, Es1, Es2}
end.
warnings(File, Ws) ->
case lists:append([W || {F, W} <- Ws, F =:= File]) of
- [] -> [];
- L -> {warnings, L}
+ [] ->
+ [];
+ L ->
+ {warnings, call_format_error(L)}
end.
+call_format_error(L) ->
+ %% Smoke test of format_error/1 to make sure that no crashes
+ %% slip through.
+ _ = [Mod:format_error(Term) || {_,Mod,Term} <- L],
+ L.
+
fail() ->
io:format("failed~n"),
?t:fail().