From cc255325934eccd108dfba55e1ad88fb62db79f8 Mon Sep 17 00:00:00 2001 From: Jared Johnson Date: Fri, 12 Sep 2014 01:23:09 -0500 Subject: [PATCH] Replace warning with slightly better testing Testing LOGWARN was generating a real warning that polluted test output. Instead, let's catch the warning and test that it actually happens. --- t/qpsmtpd.t | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/t/qpsmtpd.t b/t/qpsmtpd.t index d2b04a2..fecee7f 100644 --- a/t/qpsmtpd.t +++ b/t/qpsmtpd.t @@ -22,7 +22,17 @@ __load_logging(); done_testing(); sub __log { + my $warned = ''; + local $SIG{__WARN__} = sub { + if ( $_[0] eq "$$ test log message\n" ) { + $warned = join ' ', @_; + } + else { + warn @_; + } + }; ok( $qp->log(LOGWARN, "test log message"), 'log'); + is( $warned, "$$ test log message\n", 'LOGWARN emitted correct warning' ); } sub __config_dir {