diff options
author | Hans Bolinder <[email protected]> | 2017-06-21 15:11:00 +0200 |
---|---|---|
committer | Hans Bolinder <[email protected]> | 2017-06-22 08:50:03 +0200 |
commit | 927cbc203e9339f76f18601cd855cabc6b2c8ebb (patch) | |
tree | 63cd93bebbc3e4cb628563615c8c8856e8f20199 /lib/stdlib | |
parent | 112b7d7a1946f6b90b3497ef4c176c6d066571e2 (diff) | |
download | otp-927cbc203e9339f76f18601cd855cabc6b2c8ebb.tar.gz otp-927cbc203e9339f76f18601cd855cabc6b2c8ebb.tar.bz2 otp-927cbc203e9339f76f18601cd855cabc6b2c8ebb.zip |
stdlib: Fix bug in proc_lib
Add a few more tests to the proc_lib_SUITE.
Diffstat (limited to 'lib/stdlib')
-rw-r--r-- | lib/stdlib/src/proc_lib.erl | 4 | ||||
-rw-r--r-- | lib/stdlib/test/proc_lib_SUITE.erl | 28 |
2 files changed, 25 insertions, 7 deletions
diff --git a/lib/stdlib/src/proc_lib.erl b/lib/stdlib/src/proc_lib.erl index a00221fa6a..d4d1bdccec 100644 --- a/lib/stdlib/src/proc_lib.erl +++ b/lib/stdlib/src/proc_lib.erl @@ -779,8 +779,8 @@ format_link_report([Link|Reps], Indent, Extra) -> LinkIndent = [" ",Indent], [Indent,"neighbour:\n",format_report(Rep, LinkIndent, Extra)| format_link_report(Reps, Indent, Extra)]; -format_link_report([], _, _) -> - []. +format_link_report(Rep, Indent, Extra) -> + format_report(Rep, Indent, Extra). format_report(Rep, Indent, Extra) when is_list(Rep) -> format_rep(Rep, Indent, Extra); diff --git a/lib/stdlib/test/proc_lib_SUITE.erl b/lib/stdlib/test/proc_lib_SUITE.erl index 0d5bbdf19f..c4fafe82a4 100644 --- a/lib/stdlib/test/proc_lib_SUITE.erl +++ b/lib/stdlib/test/proc_lib_SUITE.erl @@ -78,6 +78,14 @@ end_per_group(_GroupName, Config) -> %% synchronous, and we want to test that the crash report is ok. %%----------------------------------------------------------------- crash(Config) when is_list(Config) -> + ok = application:unset_env(kernel, error_logger_format_depth), + crash_1(Config), + ok = application:set_env(kernel, error_logger_format_depth, 30), + crash_1(Config), + ok = application:unset_env(kernel, error_logger_format_depth), + ok. + +crash_1(_Config) -> error_logger:add_report_handler(?MODULE, self()), %% Make sure that we don't get a crash report if a process @@ -565,19 +573,29 @@ t_format() -> t_format_arbitrary(_Config) -> error_logger:tty(false), try - t_format_arbitrary() + t_format_arbitrary() after - error_logger:tty(true) + error_logger:tty(true) end, ok. t_format_arbitrary() -> + A = list_to_atom([1024]), + do_test_format([fake_report, A], unlimited), + do_test_format([fake_report, A], 20), + + do_test_format([fake_report, foo], unlimited), + do_test_format([fake_report, foo], 20), do_test_format([fake_report, []], unlimited), do_test_format([fake_report, []], 20). do_test_format(Report, Depth) -> - io:format("*** Depth = ~p", [Depth]), - S0 = proc_lib:format(Report, latin1, Depth), + do_test_format(Report, latin1, Depth), + do_test_format(Report, unicode, Depth). + +do_test_format(Report, Encoding, Depth) -> + io:format("*** Depth = ~p, Encoding = ~p", [Depth, Encoding]), + S0 = proc_lib:format(Report, Encoding, Depth), S = lists:flatten(S0), io:put_chars(S), length(S). @@ -597,7 +615,7 @@ init(Tester) -> {ok, Tester}. handle_event({error_report, _GL, {Pid, crash_report, Report}}, Tester) -> - io:format("~s\n", [proc_lib:format(Report)]), + io:format("~ts\n", [proc_lib:format(Report)]), Tester ! {crash_report, Pid, Report}, {ok, Tester}; handle_event(_Event, State) -> |