aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2018-09-28 16:51:42 +0200
committerLoïc Hoguin <[email protected]>2018-09-28 16:51:42 +0200
commit47391e3a48e59a9fe51f15b1e69bf98f0c3b5a5d (patch)
treee27426b5b9fb17be247e0aae92f109b34d70db17
parent46bab37b54001a110633a6f382aa102848b07795 (diff)
downloadgun-47391e3a48e59a9fe51f15b1e69bf98f0c3b5a5d.tar.gz
gun-47391e3a48e59a9fe51f15b1e69bf98f0c3b5a5d.tar.bz2
gun-47391e3a48e59a9fe51f15b1e69bf98f0c3b5a5d.zip
Improve logging in the h2specd_SUITE
-rw-r--r--test/h2specd_SUITE.erl22
1 files changed, 15 insertions, 7 deletions
diff --git a/test/h2specd_SUITE.erl b/test/h2specd_SUITE.erl
index 4a6c358..e63aadd 100644
--- a/test/h2specd_SUITE.erl
+++ b/test/h2specd_SUITE.erl
@@ -27,11 +27,18 @@ all() ->
init_per_suite(Config) ->
case os:getenv("H2SPECD") of
false -> skip;
- _ -> Config
+ _ ->
+ %% We ensure that SASL is started for this test suite
+ %% to have the crash reports in the CT logs.
+ {ok, Apps} = application:ensure_all_started(sasl),
+ [{sasl_started, Apps =/= []}|Config]
end.
-end_per_suite(_Config) ->
- ok.
+end_per_suite(Config) ->
+ case config(sasl_started, Config) of
+ true -> application:stop(sasl);
+ false -> ok
+ end.
%% Tests.
@@ -55,15 +62,16 @@ start_port(Config, Pid) ->
{spawn, H2specd ++ " -S -p 45678"},
[{line, 10000}, {cd, config(priv_dir, Config)}, binary, exit_status]),
Pid ! ready,
- receive_infinity(Port).
+ receive_infinity(Port, []).
-receive_infinity(Port) ->
+receive_infinity(Port, Acc) ->
receive
{Port, {data, {eol, Line}}} ->
- io:format(user, "~s~n", [Line]),
ct:log("~ts", [Line]),
- receive_infinity(Port);
+ io:format(user, "~s~n", [Line]),
+ receive_infinity(Port, [Line|Acc]);
{Port, Reason={exit_status, _}} ->
+ ct:log("~ts", [[[L, $\n] || L <- lists:reverse(Acc)]]),
exit({shutdown, Reason})
end.