use DBICTest::RunMode;
use DBICTest::Schema;
use Carp;
+use Path::Class::File ();
=head1 NAME
}
sub _sqlite_dbfilename {
- return "t/var/DBIxClass.db";
+ my $dir = Path::Class::File->new(__FILE__)->dir->parent->subdir('var');
+ $dir->mkpath unless -d "$dir";
+ return $dir->file('DBIxClass.db')->stringify;
}
sub _sqlite_dbname {
for ($db_file, "${db_file}-journal") {
next unless -e $_;
unlink ($_) or carp (
- "Unable to unlink existing test database file $_ ($!), creation of fresh database / further tests may fail!\n"
+ "Unable to unlink existing test database file $_ ($!), creation of fresh database / further tests may fail!"
);
}
- mkdir("t/var") unless -d "t/var";
-
return ("dbi:SQLite:${db_file}", '', '', {
AutoCommit => 1,
}
sub __mk_disconnect_guard {
+ return if DBIx::Class::_ENV_::PEEPEENESS(); # leaks handles, delaying DESTROY, can't work right
+
my $db_file = shift;
return unless -f $db_file;
if ($ENV{"DBICTEST_SQLT_DEPLOY"}) {
$schema->deploy($args);
} else {
- open IN, "t/lib/sqlite.sql";
- my $sql;
- { local $/ = undef; $sql = <IN>; }
- close IN;
+ my $filename = Path::Class::File->new(__FILE__)->dir
+ ->file('sqlite.sql')->stringify;
+ my $sql = do { local (@ARGV, $/) = $filename ; <> };
for my $chunk ( split (/;\s*\n+/, $sql) ) {
if ( $chunk =~ / ^ (?! --\s* ) \S /xm ) { # there is some real sql in the chunk - a non-space at the start of the string which is not a comment
$schema->storage->dbh_do(sub { $_[1]->do($chunk) }) or print "Error on SQL: $chunk\n";