Author: timbo Date: Mon Apr 9 14:24:28 2007 New Revision: 9388 Modified: dbi/trunk/Changes dbi/trunk/t/50dbm.t dbi/trunk/t/85gofer.t
Log: Changed tests to work with other DBMs thanks to ZMAN. Modified: dbi/trunk/Changes ============================================================================== --- dbi/trunk/Changes (original) +++ dbi/trunk/Changes Mon Apr 9 14:24:28 2007 @@ -8,6 +8,7 @@ http://buildd.debian.org/fetch.cgi?&pkg=libdbi-perl&ver=1.54-1&arch=m68k&stamp=1174636818&file=log +Pedantic policy should force a fresh connect each time - add new policy item Allow connect via subclass to support DBIx::HA prepare(...,{ Err=>\my $isolated_err, ...}) Add attr-passthru to prepare()? ie for gofer cache control @@ -36,6 +37,7 @@ it now warns and adjusts the row buffer to match. Changed DBD::NullP to be vaguely useful for testing. Changed File::Spec prerequisite to not require a minimum version. + Changed tests to work with other DBMs thanks to ZMAN. Assorted Gofer bug fixes, enhancements and docs. Added support for install_methods to DBD::Gofer. Modified: dbi/trunk/t/50dbm.t ============================================================================== --- dbi/trunk/t/50dbm.t (original) +++ dbi/trunk/t/50dbm.t Mon Apr 9 14:24:28 2007 @@ -27,12 +27,13 @@ push @mldbm_types, 'Storable' if eval { require 'Storable.pm' }; } + # Potential DBM modules in preference order (SDBM_File first) + # skip NDBM and ODBM as they don't support EXISTS + my @dbms = qw(SDBM_File GDBM_File DB_File BerkeleyDB); + if ("@ARGV" eq "all") { # test with as many of the major DBM types as are available - # skip NDBM and ODBM as they don't support EXISTS - for (qw( SDBM_File GDBM_File DB_File BerkeleyDB )) { - push @dbm_types, $_ if eval { local $^W; require "$_.pm" }; - } + @dbm_types = grep { eval { local $^W; require "$_.pm" } } @dbms; } elsif (@ARGV) { @dbm_types = @ARGV; @@ -41,7 +42,13 @@ # we only test SDBM_File by default to avoid tripping up # on any broken DBM's that may be installed in odd places. # It's only DBD::DBM we're trying to test here. - @dbm_types = ("SDBM_File"); + # (However, if SDBM_File is not available, then use another.) + for my $dbm (@dbms) { + if (eval { local $^W; require "$dbm.pm" }) { + @dbm_types = ($dbm); + last; + } + } } print "Using DBM modules: @dbm_types\n"; Modified: dbi/trunk/t/85gofer.t ============================================================================== --- dbi/trunk/t/85gofer.t (original) +++ dbi/trunk/t/85gofer.t Mon Apr 9 14:24:28 2007 @@ -17,7 +17,6 @@ plan skip_all => "transport+policy tests skipped with non-pedantic policy in DBI_AUTOPROXY" if $ap !~ /policy=pedantic\b/i; } -plan 'no_plan'; # 0=SQL::Statement if avail, 1=DBI::SQL::Nano # next line forces use of Nano rather than default behaviour @@ -27,11 +26,23 @@ my %durations; # so users can try others from the command line -my $dbm = $ARGV[0] || "SDBM_File"; +my $dbm = $ARGV[0]; +if (!$dbm) { + # pick first available, starting with SDBM_File + for (qw( SDBM_File GDBM_File DB_File BerkeleyDB )) { + if (eval { local $^W; require "$_.pm" }) { + $dbm = ($_); + last; + } + } + plan skip_all => 'No DBM modules available' if !$dbm; +} my $remote_driver_dsn = "dbm_type=$dbm;lockfile=0"; my $remote_dsn = "dbi:DBM:$remote_driver_dsn"; my $timeout = 10; +plan 'no_plan'; + if ($ENV{DBI_AUTOPROXY}) { # this means we have DBD::Gofer => DBD::Gofer => DBD::DBM! # rather than disable it we let it run because we're twisted @@ -141,7 +152,7 @@ ok $ins_sth->execute(2, 'oranges'); my $rowset; - ok $rowset = $dbh->selectall_arrayref("SELECT dKey, dVal FROM fruit"); + ok $rowset = $dbh->selectall_arrayref("SELECT dKey, dVal FROM fruit ORDER BY dKey"); is_deeply($rowset, [ [ '1', 'oranges' ], [ '2', 'oranges' ] ]); ok $dbh->do("UPDATE fruit SET dVal='apples' WHERE dVal='oranges'");
