diff --git a/t/56_open_flags.t b/t/56_open_flags.t index 5bb08df..ea4e3e3 100644 --- a/t/56_open_flags.t +++ b/t/56_open_flags.t @@ -11,7 +11,7 @@ use Test::More tests => 8; use DBI; use DBD::SQLite; -my $dbfile = 'foo'; +my $dbfile = dbfile('foo'); unlink $dbfile if -f $dbfile; { diff --git a/t/57_uri_filename.t b/t/57_uri_filename.t index 45eec76..8923a6c 100644 --- a/t/57_uri_filename.t +++ b/t/57_uri_filename.t @@ -11,12 +11,12 @@ use Test::More tests => 17; use DBI; use DBD::SQLite; -my $dbfile = 'foo'; +my $dbfile = dbfile('foo'); my %uri = ( - base => 'file:foo', - ro => 'file:foo?mode=ro', - rw => 'file:foo?mode=rw', - rwc => 'file:foo?mode=rwc', + base => "file:$dbfile", + ro => "file:$dbfile?mode=ro", + rw => "file:$dbfile?mode=rw", + rwc => "file:$dbfile?mode=rwc", ); sub cleanup { diff --git a/t/lib/Test.pm b/t/lib/Test.pm index 9376fd4..3de22c5 100644 --- a/t/lib/Test.pm +++ b/t/lib/Test.pm @@ -25,7 +25,7 @@ BEGIN { # Always load the DBI module use DBI (); -sub dbfile { $dbfiles{$_[0]} } +sub dbfile { $dbfiles{$_[0]} ||= (defined $_[0] && length $_[0] && $_[0] ne ':memory:') ? $_[0] . $$ : $_[0] } # Delete temporary files sub clean { @@ -47,9 +47,8 @@ END { clean() } # A simplified connect function for the most common case sub connect_ok { my $attr = { @_ }; - my $dbfile = defined $attr->{dbfile} ? delete $attr->{dbfile} : ':memory:'; - $dbfiles{$dbfile} = (defined $dbfile && length $dbfile && $dbfile ne ':memory:') ? $dbfile . $$ : $dbfile; - my @params = ( "dbi:SQLite:dbname=$dbfiles{$dbfile}", '', '' ); + my $dbfile = dbfile(defined $attr->{dbfile} ? delete $attr->{dbfile} : ':memory:'); + my @params = ( "dbi:SQLite:dbname=$dbfile", '', '' ); if ( %$attr ) { push @params, $attr; }