0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Silence expected errors from the stream_handler test suite

This commit is contained in:
Loïc Hoguin 2018-11-19 12:37:39 +01:00
parent ae96aa6e49
commit 66fd122c08
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764

View file

@ -29,29 +29,46 @@ all() ->
groups() ->
cowboy_test:common_groups(ct_helper:all(?MODULE)).
%% We set this module as a logger in order to silence expected errors.
init_per_group(Name = http, Config) ->
cowboy_test:init_http(Name, #{stream_handlers => [stream_handler_h]}, Config);
cowboy_test:init_http(Name, #{
logger => ?MODULE,
stream_handlers => [stream_handler_h]
}, Config);
init_per_group(Name = https, Config) ->
cowboy_test:init_https(Name, #{stream_handlers => [stream_handler_h]}, Config);
cowboy_test:init_https(Name, #{
logger => ?MODULE,
stream_handlers => [stream_handler_h]
}, Config);
init_per_group(Name = h2, Config) ->
cowboy_test:init_http2(Name, #{stream_handlers => [stream_handler_h]}, Config);
cowboy_test:init_http2(Name, #{
logger => ?MODULE,
stream_handlers => [stream_handler_h]
}, Config);
init_per_group(Name = h2c, Config) ->
Config1 = cowboy_test:init_http(Name, #{stream_handlers => [stream_handler_h]}, Config),
Config1 = cowboy_test:init_http(Name, #{
logger => ?MODULE,
stream_handlers => [stream_handler_h]
}, Config),
lists:keyreplace(protocol, 1, Config1, {protocol, http2});
init_per_group(Name = http_compress, Config) ->
cowboy_test:init_http(Name, #{
logger => ?MODULE,
stream_handlers => [cowboy_compress_h, stream_handler_h]
}, Config);
init_per_group(Name = https_compress, Config) ->
cowboy_test:init_https(Name, #{
logger => ?MODULE,
stream_handlers => [cowboy_compress_h, stream_handler_h]
}, Config);
init_per_group(Name = h2_compress, Config) ->
cowboy_test:init_http2(Name, #{
logger => ?MODULE,
stream_handlers => [cowboy_compress_h, stream_handler_h]
}, Config);
init_per_group(Name = h2c_compress, Config) ->
Config1 = cowboy_test:init_http(Name, #{
logger => ?MODULE,
stream_handlers => [cowboy_compress_h, stream_handler_h]
}, Config),
lists:keyreplace(protocol, 1, Config1, {protocol, http2}).
@ -59,6 +76,13 @@ init_per_group(Name = h2c_compress, Config) ->
end_per_group(Name, _) ->
cowboy:stop_listener(Name).
%% Logger function silencing the expected crashes.
error("Unhandled exception " ++ _, [error, crash|_]) ->
ok;
error(Format, Args) ->
error_logger:error_msg(Format, Args).
%% Tests.
crash_in_init(Config) ->