1
0
Fork 0
mirror of https://github.com/DBD-SQLite/DBD-SQLite synced 2025-06-08 06:38:12 -04:00
This commit is contained in:
Kenichi Ishigaki 2010-09-16 06:59:36 +00:00
parent a41737d141
commit d5c6e51914
6 changed files with 31 additions and 13 deletions

View file

@ -1,5 +1,8 @@
Changes for Perl extension DBD-SQLite Changes for Perl extension DBD-SQLite
1.32_01 to be released
- Resolved #61355: Fails testing in parallel (ISHIGAKI)
1.31 Wed 15 Sep 2010 1.31 Wed 15 Sep 2010
- Production release, identical to 1.30_06 - Production release, identical to 1.30_06

View file

@ -33,9 +33,12 @@ foreach my $call_func (@CALL_FUNCS) {
unless ( $] >= 5.008005 ) { unless ( $] >= 5.008005 ) {
skip( 'Unicode is not supported before 5.8.5', 2 ); skip( 'Unicode is not supported before 5.8.5', 2 );
} }
my $dbh = DBI->connect( 'dbi:SQLite:dbname=foo;sqlite_unicode=1', '', '' ); my $file = 'foo'.$$;
my $dbh = DBI->connect( "dbi:SQLite:dbname=$file;sqlite_unicode=1", '', '' );
isa_ok( $dbh, 'DBI::db' ); isa_ok( $dbh, 'DBI::db' );
is( $dbh->{sqlite_unicode}, 1, 'Unicode is on' ); is( $dbh->{sqlite_unicode}, 1, 'Unicode is on' );
$dbh->disconnect;
unlink $file;
} }
# Connect to a memory database # Connect to a memory database

View file

@ -8,7 +8,7 @@ BEGIN {
$^W = 1; $^W = 1;
} }
use t::lib::Test qw/connect_ok @CALL_FUNCS/; use t::lib::Test qw/connect_ok dbfile @CALL_FUNCS/;
use Test::More; use Test::More;
use Test::NoWarnings; use Test::NoWarnings;
@ -30,6 +30,8 @@ foreach my $call_func (@CALL_FUNCS) {
AutoCommit => 0, AutoCommit => 0,
); );
my $dbfile = dbfile('foo');
# NOTE: Let's make it clear what we're doing here. # NOTE: Let's make it clear what we're doing here.
# $dbh starts locking with the first INSERT statement. # $dbh starts locking with the first INSERT statement.
# $dbh2 tries to INSERT, but as the database is locked, # $dbh2 tries to INSERT, but as the database is locked,
@ -77,7 +79,7 @@ foreach my $call_func (@CALL_FUNCS) {
skip("No fork here", 1); skip("No fork here", 1);
} elsif (!$pid) { } elsif (!$pid) {
# child # child
my $dbh2 = DBI->connect('dbi:SQLite:foo', '', '', my $dbh2 = DBI->connect("dbi:SQLite:$dbfile", '', '',
{ {
RaiseError => 1, RaiseError => 1,
PrintError => 0, PrintError => 0,
@ -108,6 +110,6 @@ foreach my $call_func (@CALL_FUNCS) {
} }
wait; wait;
$dbh->disconnect; $dbh->disconnect;
unlink 'foo'; unlink $dbfile;
} }
} }

View file

@ -24,6 +24,7 @@ SCOPE: {
ok( $dbh->do($create2), $create2 ); ok( $dbh->do($create2), $create2 );
ok( $dbh->disconnect, '->disconnect ok' ); ok( $dbh->disconnect, '->disconnect ok' );
} }
my $dbfile = dbfile('foo');
my $pid; my $pid;
# diag("Forking... ($$)"); # diag("Forking... ($$)");
@ -36,7 +37,7 @@ if ( not defined( $pid = fork() ) ) {
# diag("Child starting... ($$)"); # diag("Child starting... ($$)");
my $dbh = DBI->connect( my $dbh = DBI->connect(
'dbi:SQLite:dbname=foo', '', '' "dbi:SQLite:dbname=$dbfile", '', ''
) or die 'connect failed'; ) or die 'connect failed';
$dbh->do($drop2) or die "DROP ok"; $dbh->do($drop2) or die "DROP ok";
$dbh->disconnect or die "disconnect ok"; $dbh->disconnect or die "disconnect ok";

View file

@ -4,7 +4,7 @@ use strict;
use warnings; use warnings;
use Test::More; use Test::More;
use t::lib::Test qw/connect_ok @CALL_FUNCS/; use t::lib::Test qw/connect_ok dbfile @CALL_FUNCS/;
BEGIN { BEGIN {
use DBD::SQLite; use DBD::SQLite;
@ -22,6 +22,7 @@ plan tests => 6 * @CALL_FUNCS + 1;
foreach my $call_func (@CALL_FUNCS) { foreach my $call_func (@CALL_FUNCS) {
# Connect to the test db and add some stuff: # Connect to the test db and add some stuff:
my $foo = connect_ok( dbfile => 'foo', RaiseError => 1 ); my $foo = connect_ok( dbfile => 'foo', RaiseError => 1 );
my $dbfile = dbfile('foo');
$foo->do( $foo->do(
'CREATE TABLE online_backup_test( id INTEGER PRIMARY KEY, foo INTEGER )' 'CREATE TABLE online_backup_test( id INTEGER PRIMARY KEY, foo INTEGER )'
); );
@ -38,7 +39,7 @@ foreach my $call_func (@CALL_FUNCS) {
{ RaiseError => 1 } { RaiseError => 1 }
); );
ok($dbh->$call_func('foo', 'backup_from_file')); ok($dbh->$call_func($dbfile, 'backup_from_file'));
{ {
my ($count) = $dbh->selectrow_array( my ($count) = $dbh->selectrow_array(
@ -54,7 +55,7 @@ foreach my $call_func (@CALL_FUNCS) {
$dbh->do("INSERT INTO online_backup_test2 (foo) VALUES ($$)"); $dbh->do("INSERT INTO online_backup_test2 (foo) VALUES ($$)");
# backup to file (foo): # backup to file (foo):
ok($dbh->$call_func('foo', 'backup_to_file')); ok($dbh->$call_func($dbfile, 'backup_to_file'));
$dbh->disconnect; $dbh->disconnect;
@ -71,5 +72,5 @@ foreach my $call_func (@CALL_FUNCS) {
} }
$dbh->disconnect; $dbh->disconnect;
unlink 'foo'; unlink $dbfile;
} }

View file

@ -9,10 +9,11 @@ use Test::More ();
use vars qw{$VERSION @ISA @EXPORT @CALL_FUNCS}; use vars qw{$VERSION @ISA @EXPORT @CALL_FUNCS};
my $parent; my $parent;
my %dbfiles;
BEGIN { BEGIN {
$VERSION = '1.31'; $VERSION = '1.31';
@ISA = 'Exporter'; @ISA = 'Exporter';
@EXPORT = qw/connect_ok dies @CALL_FUNCS/; @EXPORT = qw/connect_ok dies dbfile @CALL_FUNCS/;
# Allow tests to load modules bundled in /inc # Allow tests to load modules bundled in /inc
unshift @INC, 'inc'; unshift @INC, 'inc';
@ -23,12 +24,18 @@ BEGIN {
# Always load the DBI module # Always load the DBI module
use DBI (); use DBI ();
sub dbfile { $dbfiles{$_[0]} }
# Delete temporary files # Delete temporary files
sub clean { sub clean {
return return
if $$ != $parent; if $$ != $parent;
unlink( 'foo' ); for my $dbfile (values %dbfiles) {
unlink( 'foo-journal' ); next if $dbfile eq ':memory:';
unlink $dbfile if -f $dbfile;
my $journal = $dbfile . '-journal';
unlink $journal if -f $journal;
}
} }
# Clean up temporary test files both at the beginning and end of the # Clean up temporary test files both at the beginning and end of the
@ -40,7 +47,8 @@ END { clean() }
sub connect_ok { sub connect_ok {
my $attr = { @_ }; my $attr = { @_ };
my $dbfile = delete $attr->{dbfile} || ':memory:'; my $dbfile = delete $attr->{dbfile} || ':memory:';
my @params = ( "dbi:SQLite:dbname=$dbfile", '', '' ); $dbfiles{$dbfile} = ($dbfile ne ':memory:') ? $dbfile . $$ : $dbfile;
my @params = ( "dbi:SQLite:dbname=$dbfiles{$dbfile}", '', '' );
if ( %$attr ) { if ( %$attr ) {
push @params, $attr; push @params, $attr;
} }