On Thu Apr 22 05:00:04 2010, MJEVANS wrote:
Show quoted text> On Thu Apr 22 04:51:38 2010, MJEVANS wrote:
> > On Mon Apr 12 06:11:50 2010, BARBIE wrote:
> > > Hi BooK,
> > >
> > > Tried the latest version and got the same errors as some of the FAIL
> > > reports on my CentOS box. The attached patch appears to resolve these
> > > for me at least. However, the PrintError fix might be worth more
> > > investigation.
> > >
> > > Cheers,
> > > Barbie.
> >
> > Just to add to this report from Barbie. The first time I run
> > Test::Database with no ~/.test-database file and no
> > /tmp/Test-Database-martin I get:
> >
> > prove -vb t/10-drivers.t
> > t/10-drivers.t ..
> > 1..32
> > ok 1 - Test::Database::Driver->new() failed
> > ok 2 - Expected error message
> > ok 3 - Test::Database::Driver has a base_dir():
/tmp/Test-Database-martin
Show quoted text> > ok 4 - Test::Database::Driver's base_dir() looks like expected
> > ok 5 - Test::Database::Driver base_dir() is a directory
> > ok 6 - use Test::Database::Driver::DBM;
> > Use of uninitialized value $args{"dbd"} in concatenation (.) or string
> > at /tmp/Test-Database-1.09/blib/lib/Test/Database/Driver.pm line 55.
> > ok 7 # skip Failed to create DBM driver with Test::Database::Driver
> > (Can't locate Test/Database/Driver/.pm in @INC (@INC contains:
> > /tmp/Test-Database-1.09/blib/lib /tmp/Test-Database-1.09/blib/arch
> > /etc/perl /usr/local/lib/perl/5.10.0 /usr/local/share/perl/5.10.0
> > /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.10 /usr/share/perl/5.10
> > /usr/local/lib/site_perl .))
> >
> > The uninitialized value warning is down to the code Barbie refers to:
> >
> > sub new {
> > my ( $class, %args ) = @_;
> >
> > if ( $class eq __PACKAGE__ ) {
> > if ( exists $args{driver_dsn} ) {
> > my ( $scheme, $driver, $attr_string, $attr_hash,
$driver_dsn )
Show quoted text> > = DBI->parse_dsn( $args{driver_dsn} );
> > $args{dbd} = $driver;
> > }
> > croak "dbd or driver_dsn parameter required" if !exists
> $args{dbd};
> > eval "require Test::Database::Driver::$args{dbd}"
> > or do { $@ =~ s/ at .*?\z//s; croak $@; };
> > $class = "Test::Database::Driver::$args{dbd}";
> > $class->__init();
> > }
> >
> > Where %args contains:
> >
> > $VAR1 = {
> > 'password' => '',
> > 'driver_dsn' => undef,
> > 'dbd' => 'DBM',
> > 'username' => ''
> > };
> >
> > on entry hence "exists $args{driver_dsn}" is true and DBI's parse_dsn is
> > called with an empty $args{driver_dsn} hence $driver is undef and
> > assigned to $args{dbd} and the eval fails. Barbie's change fixed that
> > for me.
> >
> > Having run once it works but you can make it fail again my deleting
> > /tmp/Test-Database-martin
> >
> > Martin
>
> However, I think it is unwise to call DBI's parse_dsn with an undefined
> value so I think the following is better:
>
> sub new {
> my ( $class, %args ) = @_;
>
> if ( $class eq __PACKAGE__ ) {
>
> if ( exists $args{driver_dsn} && defined($args{driver_dsn})) {
> my ( $scheme, $driver, $attr_string, $attr_hash, $driver_dsn )
> = DBI->parse_dsn( $args{driver_dsn} );
> $args{dbd} = $driver;
> }
> croak "dbd or driver_dsn parameter required" unless(exists
> $args{dbd} && $args{dbd});
> #croak "dbd or driver_dsn parameter required" if !exists
$args{dbd};
Show quoted text> eval "require Test::Database::Driver::$args{dbd}"
> or do { $@ =~ s/ at .*?\z//s; croak $@; };
> $class = "Test::Database::Driver::$args{dbd}";
> $class->__init();
> }
However, I think it is unwise to call DBI's parse_dsn with an undefined
value and this leads to other warnings later. The following is better
for me:
sub new {
my ( $class, %args ) = @_;
if ( $class eq __PACKAGE__ ) {
# added defined in the following:
if ( exists $args{driver_dsn} && defined($args{driver_dsn})) {
my ( $scheme, $driver, $attr_string, $attr_hash, $driver_dsn )
= DBI->parse_dsn( $args{driver_dsn} );
$args{dbd} = $driver;
}
croak "dbd or driver_dsn parameter required" unless(exists
$args{dbd} && $args{dbd});
#croak "dbd or driver_dsn parameter required" if !exists $args{dbd};
eval "require Test::Database::Driver::$args{dbd}"
or do { $@ =~ s/ at .*?\z//s; croak $@; };
$class = "Test::Database::Driver::$args{dbd}";
$class->__init();
}
Martin
--
Martin J. Evans
Wetherby, UK