use Test::More;
use Test::Exception;
+use Try::Tiny;
use lib qw(t/lib);
use DBICTest;
use Path::Class qw/file/;
}
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
{