1 package dbixcsl_test_dir;
5 use File::Path 'rmtree';
6 use File::Temp 'tempdir';
7 use Scalar::Util 'weaken';
11 use base qw/Exporter/;
12 our @EXPORT_OK = '$tdir';
14 die "/t does not exist, this can't be right...\n"
20 mkdir $tbdir or die "Unable to create $tbdir: $!\n";
23 our $tdir = tempdir(DIR => $tbdir);
25 # We need to disconnect all active DBI handles before deleting the directory,
26 # otherwise the SQLite .db files cannot be deleted on Win32 (file in use) since
27 # END does not run in any sort of order.
29 no warnings 'redefine';
31 my $connect = \&DBI::connect;
36 my $dbh = $connect->(@_);
43 if (not $ENV{SCHEMA_LOADER_TESTS_NOCLEANUP}) {
44 foreach my $dbh (@handles) {
45 $dbh->disconnect if $dbh;
49 rmdir($tbdir); # remove if empty, ignore otherwise