use warnings;
use DBICTest::Util 'local_umask';
-use DBICTest::RunMode;
+use DBICTest::Schema;
use DBICTest::Util::LeakTracer qw/populate_weakregistry assert_empty_weakregistry/;
+use DBIx::Class::_Util 'detected_reinvoked_destructor';
use Carp;
use Path::Class::File ();
use File::Spec;
$SIG{INT} = sub { _cleanup_dbfile(); exit 1 };
+my $need_global_cleanup;
sub _cleanup_dbfile {
# cleanup if this is us
if (
or
$ENV{DBICTEST_LOCK_HOLDER} == $$
) {
+ if ($need_global_cleanup and my $dbh = DBICTest->schema->storage->_dbh) {
+ $dbh->disconnect;
+ }
+
my $db_file = _sqlite_dbfilename();
unlink $_ for ($db_file, "${db_file}-journal");
}
$dbh->{Callbacks} = {
connect => sub { $guard_cb->('connect') },
disconnect => sub { $guard_cb->('disconnect') },
- DESTROY => sub { $guard_cb->('DESTROY') },
+ DESTROY => sub { &detected_reinvoked_destructor; $guard_cb->('DESTROY') },
};
}
},
my $schema;
- require DBICTest::Schema;
-
if ($args{compose_connection}) {
+ $need_global_cleanup = 1;
$schema = DBICTest::Schema->compose_connection(
'DBICTest', $self->_database(%args)
);
END {
# Make sure we run after any cleanup in other END blocks
- require B;
push @{ B::end_av()->object_2svref }, sub {
assert_empty_weakregistry($weak_registry, 'quiet');
};
]);
}
-sub connect_schema {
- my $self = shift;
- require DBICTest::Schema;
- return DBICTest::Schema->connect(@_);
-}
-
1;