Author: turnstep
Date: Tue Jul 22 21:32:20 2008
New Revision: 11575
Modified:
DBD-Pg/trunk/t/01connect.t
DBD-Pg/trunk/t/dbdpg_test_setup.pl
Log:
During test, fully commit to testuser, which may fix the odd testing error sometimes seen.
Modified: DBD-Pg/trunk/t/01connect.t
==============================================================================
--- DBD-Pg/trunk/t/01connect.t (original)
+++ DBD-Pg/trunk/t/01connect.t Tue Jul 22 21:32:20 2008
@@ -36,9 +36,9 @@
ok ($dbh->disconnect(), 'Disconnect from the database');
# Connect two times. From this point onward, do a simpler connection check
-$dbh = connect_database();
-
-pass ('Connected with first database handle');
+$t=q{Second database connection attempt worked};
+(undef,$connerror,$dbh) = connect_database();
+is ($connerror, '', $t);
## Grab some important values used for debugging
my @vals = qw/array_nulls backslash_quote server_encoding client_encoding standard_conforming_strings/;
@@ -134,6 +134,9 @@
if ($helpconnect & 4) {
$extra .= 'DBI_USER';
}
+ if ($helpconnect & 8) {
+ $extra .= 'DBI_USERx2';
+ }
if ($helpconnect & 16) {
$extra .= 'initdb';
}
Modified: DBD-Pg/trunk/t/dbdpg_test_setup.pl
==============================================================================
--- DBD-Pg/trunk/t/dbdpg_test_setup.pl (original)
+++ DBD-Pg/trunk/t/dbdpg_test_setup.pl Tue Jul 22 21:32:20 2008
@@ -312,46 +312,39 @@
unshift @userlist, $username if defined $username and $username ne getpwent;
my %doneuser;
- for my $user (@userlist) {
- next if $doneuser{$user}++;
- $uid = (getpwnam $user)[2];
+ for $testuser (@userlist) {
+ next if $doneuser{$testuser}++;
+ $uid = (getpwnam $testuser)[2];
next if !defined $uid;
next unless chown $uid, -1, $testdir;
next unless chown $uid, -1, $readme;
- $su = $user;
+ $su = $testuser;
$founduser++;
$info = '';
my $olddir = getcwd;
eval {
chdir $testdir;
- $info = qx{su -m $user -c "$initdb --locale=C -E UTF8 -D $testdir/data 2>&1"};
+ $info = qx{su -m $testuser -c "$initdb --locale=C -E UTF8 -D $testdir/data 2>&1"};
};
my $err = $@;
chdir $olddir;
- if (!$err and $info =~ /owned by user "$user"/) {
- $testuser = $user;
- last;
- }
+ last if !$err;
}
if (!$founduser) {
$@ = 'Unable to find a user to run initdb as';
- last GETHANDLE;
- }
- if (!$testuser) {
- $@ = "Failed to run initdb as user $su: $@";
- last GETHANDLE;
+ last GETHANDLE; ## Fail - no user
}
if (! -e "$testdir/data") {
$@ = 'Could not create a test database via initdb';
- last GETHANDLE;
+ last GETHANDLE; ## Fail - no datadir created
}
## At this point, both $su and $testuser are set
}
if ($info =~ /FATAL/) {
$@ = "initdb gave a FATAL error: $info";
- last GETHANDLE;
+ last GETHANDLE; ## Fail - FATAL
}
if ($info =~ /but is not empty/) {
@@ -359,7 +352,7 @@
}
elsif ($info !~ /pg_ctl/) {
$@ = "initdb did not give a pg_ctl string: $info";
- last GETHANDLE;
+ last GETHANDLE; ## Fail - bad output
}
## Which user do we connect as?
@@ -389,7 +382,7 @@
}
if ($testport >= $maxport) {
$@ = "No free ports found for testing: tried 5440 to $maxport\n";
- last GETHANDLE;
+ last GETHANDLE; ## Fail - no free ports
}
}
$@ = '';
@@ -398,7 +391,7 @@
my $cfh;
if (! open $cfh, '>>', $conf) {
$@ = qq{Could not open "$conf": $!};
- last GETHANDLE;
+ last GETHANDLE; ## Fail - no conf file
}
print $cfh "\n\n## DBD::Pg testing parameters\nport=$testport\nmax_connections=4\n";
print $cfh "listen_addresses='localhost'\n" if $^O =~ /Win32/;
@@ -437,7 +430,7 @@
$su and chdir $olddir;
if ($err or $info !~ /\w/) {
$@ = "Could not startup new database ($COM) ($err) ($info)";
- last GETHANDLE;
+ last GETHANDLE; ## Fail - startup failed
}
sleep 1;
}
@@ -462,7 +455,7 @@
redo STARTUP;
}
}
- last GETHANDLE;
+ last GETHANDLE; ## Made it!
}
} ## end of GETHANDLE
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.