use Test::More;
use Test::Exception;
+use Try::Tiny;
use lib qw(t/lib);
use DBICTest;
-use DBIC::SqlMakerTest;
use Path::Class qw/file/;
BEGIN { delete @ENV{qw(DBIC_TRACE DBIC_TRACE_PROFILE DBICTEST_SQLITE_USE_FILE)} }
ok ( $schema->storage->debug(1), 'debug' );
$schema->storage->debugfh($lfn->openw);
-$schema->storage->debugfh->autoflush(1);
$schema->resultset('CD')->count;
my @loglines = $lfn->slurp;
}
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
{