aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Carlsson <[email protected]>2012-02-15 16:43:31 +0100
committerFredrik Gustafsson <[email protected]>2012-08-10 10:57:22 +0200
commitdab05b72fa5cfd383f1eac5525ac671a15c5cbf6 (patch)
treea2c74df5dea8c5db6613c8dedea31b20769ae27d
parent975a3d513f3e112fa12b4de366ad54ac68b46b6e (diff)
downloadotp-dab05b72fa5cfd383f1eac5525ac671a15c5cbf6.tar.gz
otp-dab05b72fa5cfd383f1eac5525ac671a15c5cbf6.tar.bz2
otp-dab05b72fa5cfd383f1eac5525ac671a15c5cbf6.zip
improved layout of error messages - stack trace before error term
-rw-r--r--lib/eunit/src/eunit_lib.erl23
-rw-r--r--lib/eunit/src/eunit_tty.erl4
2 files changed, 14 insertions, 13 deletions
diff --git a/lib/eunit/src/eunit_lib.erl b/lib/eunit/src/eunit_lib.erl
index c700989bae..5d7025f038 100644
--- a/lib/eunit/src/eunit_lib.erl
+++ b/lib/eunit/src/eunit_lib.erl
@@ -59,8 +59,9 @@ format_exception({Class,Term,Trace}, Depth)
when is_atom(Class), is_list(Trace) ->
case is_stacktrace(Trace) of
true ->
- io_lib:format("~w:~P\n~s",
- [Class, Term, Depth, format_stacktrace(Trace)]);
+ io_lib:format("~s**~w:~s",
+ [format_stacktrace(Trace), Class,
+ format_term(Term, Depth)]);
false ->
format_term(Term, Depth)
end;
@@ -103,7 +104,7 @@ format_stacktrace(Trace) ->
format_stacktrace(Trace, "in function", "in call from").
format_stacktrace([{M,F,A,L}|Fs], Pre, Pre1) when is_integer(A) ->
- [io_lib:fwrite(" ~s ~w:~w/~w~s\n",
+ [io_lib:fwrite("~s ~w:~w/~w~s\n",
[Pre, M, F, A, format_stacktrace_location(L)])
| format_stacktrace(Fs, Pre1, Pre1)];
format_stacktrace([{M,F,As,L}|Fs], Pre, Pre1) when is_list(As) ->
@@ -119,7 +120,7 @@ format_stacktrace([{M,F,As,L}|Fs], Pre, Pre1) when is_list(As) ->
false ->
io_lib:fwrite("~w(~s)", [F,format_arglist(As)])
end,
- [io_lib:fwrite(" ~s ~w:~w/~w~s\n called as ~s\n",
+ [io_lib:fwrite("~s ~w:~w/~w~s\n called as ~s\n",
[Pre,M,F,A,format_stacktrace_location(L),C])
| format_stacktrace(Fs,Pre1,Pre1)];
format_stacktrace([{M,F,As}|Fs], Pre, Pre1) ->
@@ -181,23 +182,23 @@ format_error({instantiation_failed, Exception}) ->
[format_exception(Exception)]).
error_msg(Title, Fmt, Args) ->
- Msg = io_lib:format("::"++Fmt, Args), % gets indentation right
+ Msg = io_lib:format("**"++Fmt, Args), % gets indentation right
io_lib:fwrite("*** ~s ***\n~s\n\n", [Title, Msg]).
-ifdef(TEST).
format_exception_test_() ->
[?_assertMatch(
- "error:dummy"++_,
- lists:flatten(
+ "\nymmud:rorre"++_,
+ lists:reverse(lists:flatten(
format_exception(try erlang:error(dummy)
catch C:R -> {C, R, erlang:get_stacktrace()}
- end))),
+ end)))),
?_assertMatch(
- "error:dummy"++_,
- lists:flatten(
+ "\nymmud:rorre"++_,
+ lists:reverse(lists:flatten(
format_exception(try erlang:error(dummy, [a])
catch C:R -> {C, R, erlang:get_stacktrace()}
- end)))].
+ end))))].
-endif.
%% ---------------------------------------------------------------------
diff --git a/lib/eunit/src/eunit_tty.erl b/lib/eunit/src/eunit_tty.erl
index a8cec86ade..f21b2da3d3 100644
--- a/lib/eunit/src/eunit_tty.erl
+++ b/lib/eunit/src/eunit_tty.erl
@@ -213,7 +213,7 @@ print_test_end(Data) ->
print_test_error({error, Exception}, Data) ->
Output = proplists:get_value(output, Data),
- fwrite("*failed*\n::~s", [eunit_lib:format_exception(Exception)]),
+ fwrite("*failed*\n~s", [eunit_lib:format_exception(Exception)]),
case Output of
<<>> ->
fwrite("\n\n");
@@ -228,7 +228,7 @@ print_test_error({skipped, Reason}, _) ->
format_skipped({module_not_found, M}) ->
io_lib:fwrite("missing module: ~w", [M]);
format_skipped({no_such_function, {M,F,A}}) ->
- io_lib:fwrite("no such function: ~w:~w/~w", [M,F,A]).
+ io_lib:fwrite("no such function: ~w:~w/~w", [M,F,A]).
print_test_cancel(Reason) ->
fwrite(format_cancel(Reason)).