Skip to content

Commit

Permalink
use Path::Class for finding subdirs of t and don't use global filehan…
Browse files Browse the repository at this point in the history
…dle for slurping
  • Loading branch information
abraxxa committed Jan 3, 2012
1 parent 7f7f54c commit de306d4
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions t/lib/DBICTest.pm
Expand Up @@ -6,6 +6,7 @@ use warnings;
use DBICTest::RunMode;
use DBICTest::Schema;
use Carp;
use Path::Class::File ();

=head1 NAME
Expand Down Expand Up @@ -53,7 +54,9 @@ sub has_custom_dsn {
}

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 {
Expand Down Expand Up @@ -82,8 +85,6 @@ sub _database {
);
}

mkdir("t/var") unless -d "t/var";

return ("dbi:SQLite:${db_file}", '', '', {
AutoCommit => 1,

Expand Down Expand Up @@ -230,10 +231,9 @@ sub deploy_schema {
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";
Expand Down

0 comments on commit de306d4

Please sign in to comment.