From: Peter Rabbitson Date: Mon, 7 Jul 2014 22:34:24 +0000 (+0200) Subject: Expand closed STDERR test, check actual exception X-Git-Tag: v0.082800~156 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=68367f1f7fb5dd2d13931ec85c3a9bbb415f8359;p=dbsrgits%2FDBIx-Class.git Expand closed STDERR test, check actual exception --- diff --git a/t/storage/debug.t b/t/storage/debug.t index d16e129..ce85bc5 100644 --- a/t/storage/debug.t +++ b/t/storage/debug.t @@ -4,6 +4,7 @@ no warnings 'once'; use Test::More; use Test::Exception; +use Try::Tiny; use lib qw(t/lib); use DBICTest; use Path::Class qw/file/; @@ -53,12 +54,21 @@ END { } open(STDERRCOPY, '>&STDERR'); -close(STDERR); -dies_ok { + +# STDERR will be closed, no T::B diag in blocks +my $exception = try { + close(STDERR); $schema->resultset('CD')->search({})->count; -} 'Died on closed FH'; +} catch { + $_ +} finally { + # restore STDERR + open(STDERR, '>&STDERRCOPY'); +}; + +like $exception, qr/\QDuplication of STDERR for debug output failed (perhaps your STDERR is closed?)/; + -open(STDERR, '>&STDERRCOPY'); # test debugcb and debugobj protocol {