From: Alexander Hartmaier Date: Tue, 3 Jan 2012 12:00:47 +0000 (+0100) Subject: use Path::Class for finding subdirs of t and don't use global filehandle for slurping X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=de306d4b5efbb887c662589a8173925e3f96960a;p=dbsrgits%2FDBIx-Class-Historic.git use Path::Class for finding subdirs of t and don't use global filehandle for slurping --- diff --git a/t/lib/DBICTest.pm b/t/lib/DBICTest.pm index e67c02a..b4a60aa 100644 --- a/t/lib/DBICTest.pm +++ b/t/lib/DBICTest.pm @@ -6,6 +6,7 @@ use warnings; use DBICTest::RunMode; use DBICTest::Schema; use Carp; +use Path::Class::File (); =head1 NAME @@ -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 { @@ -82,8 +85,6 @@ sub _database { ); } - mkdir("t/var") unless -d "t/var"; - return ("dbi:SQLite:${db_file}", '', '', { AutoCommit => 1, @@ -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 = ; } - 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";