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

Silence expected test error reports from the console output

The errors are still logged by common_test to the report it creates.
The process that is going to crash has to call cowboy_error_h:ignore/3
with the MFA where the crash is expected to occur for it to be ignored.
Gun retry failures are also ignored. Only unexpected crashes are printed.
This commit is contained in:
Loïc Hoguin 2014-04-21 21:22:08 +02:00
parent 74512fc84c
commit 75218c4be0
6 changed files with 124 additions and 7 deletions

22
test/cowboy_ct_hook.erl Normal file
View file

@ -0,0 +1,22 @@
%% Copyright (c) 2014, Loïc Hoguin <essen@ninenines.eu>
%%
%% Permission to use, copy, modify, and/or distribute this software for any
%% purpose with or without fee is hereby granted, provided that the above
%% copyright notice and this permission notice appear in all copies.
%%
%% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
%% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
%% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
%% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
%% WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
%% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
%% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-module(cowboy_ct_hook).
-export([init/2]).
init(_, _) ->
error_logger:tty(false),
error_logger:add_report_handler(cowboy_error_h),
{ok, undefined}.