mirror of
https://github.com/DBD-SQLite/DBD-SQLite
synced 2025-06-07 14:19:10 -04:00
Rewrote to use Test::More
This commit is contained in:
parent
5e7f3ea9a6
commit
a95211acc0
1 changed files with 21 additions and 21 deletions
|
@ -9,7 +9,7 @@ BEGIN {
|
|||
$^W = 1;
|
||||
}
|
||||
|
||||
use Test::More tests => 5;
|
||||
use Test::More tests => 9;
|
||||
use t::lib::Test;
|
||||
|
||||
my $create1 = 'CREATE TABLE table1 (id INTEGER NOT NULL, name CHAR (64) NOT NULL)';
|
||||
|
@ -17,15 +17,11 @@ my $create2 = 'CREATE TABLE table2 (id INTEGER NOT NULL, name CHAR (64) NOT NULL
|
|||
my $drop1 = 'DROP TABLE table1';
|
||||
my $drop2 = 'DROP TABLE table2';
|
||||
|
||||
# diag("Parent starting... ($$)");
|
||||
|
||||
# Create the tables
|
||||
SCOPE: {
|
||||
my $dbh = DBI->connect('dbi:SQLite:dbname=foo', '', '') or die 'connect failed';
|
||||
$dbh->do($create1) or die '$create1 failed';
|
||||
$dbh->do($create2) or die '$create2 failed';
|
||||
$dbh->disconnect or die 'disconnect failed';
|
||||
}
|
||||
# diag("Parent connecting... ($$)\n");
|
||||
my $dbh = connect_ok();
|
||||
ok( $dbh->do($create1), $create1 );
|
||||
ok( $dbh->do($create2), $create2 );
|
||||
ok( $dbh->disconnect, '->disconnect ok' );
|
||||
|
||||
my $pid;
|
||||
# diag("Forking... ($$)");
|
||||
|
@ -33,25 +29,29 @@ if ( not defined( $pid = fork() ) ) {
|
|||
die("fork: $!");
|
||||
|
||||
} elsif ( $pid == 0 ) {
|
||||
# Child process
|
||||
# Pause to let the parent connect
|
||||
sleep(2);
|
||||
|
||||
# diag("Child starting... ($$)");
|
||||
my $dbh = connect_ok();
|
||||
ok( $dbh->do($drop2), $drop2 );
|
||||
ok( $dbh->disconnect, '->disconnect ok' );
|
||||
my $dbh = DBI->connect(
|
||||
'dbi:SQLite:dbname=foo', '', ''
|
||||
) or die 'connect failed';
|
||||
$dbh->do($drop2) or die "DROP ok";
|
||||
$dbh->disconnect or die "disconnect ok";
|
||||
# diag("Child exiting... ($$)");
|
||||
|
||||
exit(0);
|
||||
|
||||
} else {
|
||||
}
|
||||
|
||||
SCOPE: {
|
||||
# Parent process
|
||||
# diag("Waiting for child... ($$)");
|
||||
ok( waitpid($pid, 0) != -1, "waitpid" );
|
||||
|
||||
}
|
||||
|
||||
# Make sure the child actually deleted table2
|
||||
SCOPE: {
|
||||
# Make sure the child actually deleted table2
|
||||
my $dbh = connect_ok();
|
||||
ok( $dbh->do($drop1), $drop1 );
|
||||
ok( $dbh->do($create2), $create2 );
|
||||
ok( $dbh->do($drop1), $drop1 ) or diag("Error: '$DBI::errstr'");
|
||||
ok( $dbh->do($create2), $create2 ) or diag("Error: '$DBI::errstr'");
|
||||
ok( $dbh->disconnect, '->disconnect ok' );
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue