Author: turnstep
Date: Fri Jan 11 13:25:14 2008
New Revision: 10522
Modified:
DBD-Pg/trunk/t/01connect.t
Log:
Handle undefined vars better if we die early, refuse to do any more tests if
DBI_DSN is not set.
Modified: DBD-Pg/trunk/t/01connect.t
==============================================================================
--- DBD-Pg/trunk/t/01connect.t (original)
+++ DBD-Pg/trunk/t/01connect.t Fri Jan 11 13:25:14 2008
@@ -9,15 +9,16 @@
select((select(STDERR),$|=1)[0]);
$|=1;
+## Define this here in case we get to the END block before a connection is
made.
+my ($pgversion,$pglibversion,$pgvstring,$pgdefport) = ('?','?','?','?');
+
+my $bail = 0;
if (defined $ENV{DBI_DSN}) {
plan tests => 15;
} else {
- plan skip_all => 'Cannot run test unless DBI_DSN is defined. See the
README file.';
+ BAIL_OUT "DBI_DSN must be set";
}
-## Define this here in case we get to the END block before a connection is
made.
-my ($pgversion,$pglibversion,$pgvstring,$pgdefport) = ('?','?','?','?');
-
# Trapping a connection error can be tricky, but we only have to do it
# this thoroughly one time. We are trapping two classes of errors:
# the first is when we truly do not connect, usually a bad DBI_DSN;
@@ -117,14 +118,16 @@
my $pv = sprintf("%vd", $^V);
my $schema = exists $ENV{DBD_SCHEMA} ?
"\nDBD_SCHEMA $ENV{DBD_SCHEMA}" : '';
+ my $dsn = exists $ENV{DBI_DSN} ? $ENV{DBI_DSN} : '?';
+ my $ver = defined $DBD::Pg::VERSION ? $DBD::Pg::VERSION : '?';
diag
"\nProgram Version\n".
"Perl $pv ($^O)\n".
- "DBD::Pg $DBD::Pg::VERSION\n".
+ "DBD::Pg $ver\n".
"PostgreSQL (compiled) $pglibversion\n".
"PostgreSQL (target) $pgversion\n".
"PostgreSQL (reported) $pgvstring\n".
"Default port $pgdefport\n".
"DBI $DBI::VERSION\n".
- "DBI_DSN $ENV{DBI_DSN}$schema\n";
+ "DBI_DSN $dsn$schema\n";
}