From: Jerry D. Hedden Date: Mon, 2 Apr 2007 10:15:47 +0000 (-0700) Subject: Allow testing of DBM_Filter with any *DBM_File X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e8ebc68a01b9d0ab87b23ad80d141e3fde235b2f;p=p5sagit%2Fp5-mst-13.2.git Allow testing of DBM_Filter with any *DBM_File From: "Jerry D. Hedden" Message-ID: <642435.53086.qm@web30215.mail.mud.yahoo.com> p4raw-id: //depot/perl@30833 --- diff --git a/lib/DBM_Filter/t/01error.t b/lib/DBM_Filter/t/01error.t index f66030a..e16d8d1 100644 --- a/lib/DBM_Filter/t/01error.t +++ b/lib/DBM_Filter/t/01error.t @@ -45,7 +45,17 @@ print "# runFilter $name\n" ; use Test::More tests => 21; BEGIN { use_ok('DBM_Filter') }; -BEGIN { use_ok('SDBM_File') }; +my $db_file; +BEGIN { + use Config; + foreach (qw/ODBM_File SDBM_File NDBM_File GDBM_File DB_File/) { + if ($Config{extensions} =~ /\b$_\b/) { + $db_file = $_; + last; + } + } + use_ok($db_file); +}; BEGIN { use_ok('Fcntl') }; unlink ; @@ -53,9 +63,9 @@ END { unlink ; } my %h1 = () ; my %h2 = () ; -$db = tie(%h1, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; +$db = tie(%h1, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; -ok $db, "tied to SDBM_File ok"; +ok $db, "tied to $db_file ok"; # Error cases diff --git a/lib/DBM_Filter/t/02core.t b/lib/DBM_Filter/t/02core.t index 77a6a6c..a9538e5 100644 --- a/lib/DBM_Filter/t/02core.t +++ b/lib/DBM_Filter/t/02core.t @@ -33,7 +33,17 @@ END { unlink keys %files if keys %files } use Test::More tests => 189; BEGIN { use_ok('DBM_Filter') }; -BEGIN { use_ok('SDBM_File') }; +my $db_file; +BEGIN { + use Config; + foreach (qw/SDBM_File ODBM_File NDBM_File GDBM_File DB_File/) { + if ($Config{extensions} =~ /\b$_\b/) { + $db_file = $_; + last; + } + } + use_ok($db_file); +}; BEGIN { use_ok('Fcntl') }; unlink ; @@ -151,7 +161,7 @@ sub checkRaw my %h; # read the dbm file without the filter - ok tie(%h, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640), "tied to SDBM_File"; + ok tie(%h, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640), "tied to $db_file"; my %bad = (); while (my ($k, $v) = each %h) { @@ -188,8 +198,8 @@ sub checkRaw #diag "Test Set: Key and Value Filter, no stacking, no closure"; my %h = () ; - my $db = tie(%h, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; - ok $db, "tied to SDBM_File"; + my $db = tie(%h, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; + ok $db, "tied to $db_file"; doPreData(\%h); @@ -218,8 +228,8 @@ sub checkRaw #diag "Test Set: Key Only Filter, no stacking, no closure"; my %h = () ; - my $db = tie(%h, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; - ok $db, "tied to SDBM_File"; + my $db = tie(%h, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; + ok $db, "tied to $db_file"; doPreData(\%h); @@ -248,8 +258,8 @@ sub checkRaw #diag "Test Set: Value Only Filter, no stacking, no closure"; my %h = () ; - my $db = tie(%h, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; - ok $db, "tied to SDBM_File"; + my $db = tie(%h, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; + ok $db, "tied to $db_file"; doPreData(\%h); @@ -278,8 +288,8 @@ sub checkRaw #diag "Test Set: Key and Value Filter, with stacking, no closure"; my %h = () ; - my $db = tie(%h, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; - ok $db, "tied to SDBM_File"; + my $db = tie(%h, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; + ok $db, "tied to $db_file"; doPreData(\%h); @@ -311,8 +321,8 @@ sub checkRaw #diag "Test Set: Key Filter != Value Filter, with stacking, no closure"; my %h = () ; - my $db = tie(%h, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; - ok $db, "tied to SDBM_File"; + my $db = tie(%h, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; + ok $db, "tied to $db_file"; doPreData(\%h); @@ -350,8 +360,8 @@ sub checkRaw #diag "Test Set: Key only Filter, with stacking, no closure"; my %h = () ; - my $db = tie(%h, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; - ok $db, "tied to SDBM_File"; + my $db = tie(%h, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; + ok $db, "tied to $db_file"; doPreData(\%h); @@ -383,8 +393,8 @@ sub checkRaw #diag "Test Set: Value only Filter, with stacking, no closure"; my %h = () ; - my $db = tie(%h, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; - ok $db, "tied to SDBM_File"; + my $db = tie(%h, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; + ok $db, "tied to $db_file"; doPreData(\%h); @@ -416,8 +426,8 @@ sub checkRaw #diag "Test Set: Combination Key/Value + Key Filter != Value Filter, with stacking, no closure"; my %h = () ; - my $db = tie(%h, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; - ok $db, "tied to SDBM_File"; + my $db = tie(%h, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; + ok $db, "tied to $db_file"; doPreData(\%h); @@ -452,8 +462,8 @@ sub checkRaw #diag "Test Set: Combination Key/Value + Key + Key/Value, no closure"; my %h = () ; - my $db = tie(%h, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; - ok $db, "tied to SDBM_File"; + my $db = tie(%h, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; + ok $db, "tied to $db_file"; doPreData(\%h); @@ -488,8 +498,8 @@ sub checkRaw #diag "Test Set: Combination Key/Value + Key + Key/Value, with closure"; my %h = () ; - my $db = tie(%h, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; - ok $db, "tied to SDBM_File"; + my $db = tie(%h, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; + ok $db, "tied to $db_file"; doPreData(\%h); @@ -524,8 +534,8 @@ sub checkRaw #diag "Test Set: Combination Key/Value + Key + Key/Value, immediate"; my %h = () ; - my $db = tie(%h, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; - ok $db, "tied to SDBM_File"; + my $db = tie(%h, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; + ok $db, "tied to $db_file"; doPreData(\%h); @@ -569,8 +579,8 @@ sub checkRaw #diag "Test Set: Combination Key/Value + Key + Key/Value, immediate, closure"; my %h = () ; - my $db = tie(%h, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; - ok $db, "tied to SDBM_File"; + my $db = tie(%h, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; + ok $db, "tied to $db_file"; doPreData(\%h); @@ -608,8 +618,8 @@ sub checkRaw #diag "Test Set: Filtered & Filter_Pop"; my %h = () ; - my $db = tie(%h, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; - ok $db, "tied to SDBM_File"; + my $db = tie(%h, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; + ok $db, "tied to $db_file"; doPreData(\%h); @@ -692,8 +702,8 @@ sub checkRaw } my %h = () ; - my $db = tie(%h, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; - ok $db, "tied to SDBM_File"; + my $db = tie(%h, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; + ok $db, "tied to $db_file"; doPreData(\%h); diff --git a/lib/DBM_Filter/t/compress.t b/lib/DBM_Filter/t/compress.t index b7f04bb..f9b1fe1 100644 --- a/lib/DBM_Filter/t/compress.t +++ b/lib/DBM_Filter/t/compress.t @@ -17,7 +17,17 @@ require "dbm_filter_util.pl"; use Test::More tests => 23; BEGIN { use_ok('DBM_Filter') }; -BEGIN { use_ok('SDBM_File') }; +my $db_file; +BEGIN { + use Config; + foreach (qw/SDBM_File ODBM_File NDBM_File GDBM_File DB_File/) { + if ($Config{extensions} =~ /\b$_\b/) { + $db_file = $_; + last; + } + } + use_ok($db_file); +}; BEGIN { use_ok('Fcntl') }; BEGIN { use_ok('Compress::Zlib') }; @@ -25,9 +35,9 @@ unlink ; END { unlink ; } my %h1 = () ; -my $db1 = tie(%h1, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; +my $db1 = tie(%h1, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; -ok $db1, "tied to SDBM_File"; +ok $db1, "tied to $db_file"; # store before adding the filter @@ -80,9 +90,9 @@ undef $db1; # read the dbm file without the filter my %h2 = () ; -my $db2 = tie(%h2, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; +my $db2 = tie(%h2, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; -ok $db2, "tied to SDBM_File"; +ok $db2, "tied to $db_file"; VerifyData(\%h2, { diff --git a/lib/DBM_Filter/t/encode.t b/lib/DBM_Filter/t/encode.t index 2c3ee0b..b60fbb5 100644 --- a/lib/DBM_Filter/t/encode.t +++ b/lib/DBM_Filter/t/encode.t @@ -21,7 +21,17 @@ require "dbm_filter_util.pl"; use Test::More tests => 26; BEGIN { use_ok('DBM_Filter') }; -BEGIN { use_ok('SDBM_File') }; +my $db_file; +BEGIN { + use Config; + foreach (qw/SDBM_File ODBM_File NDBM_File GDBM_File DB_File/) { + if ($Config{extensions} =~ /\b$_\b/) { + $db_file = $_; + last; + } + } + use_ok($db_file); +}; BEGIN { use_ok('Fcntl') }; BEGIN { use_ok('charnames', qw{greek})}; @@ -31,9 +41,9 @@ unlink ; END { unlink ; } my %h1 = () ; -my $db1 = tie(%h1, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; +my $db1 = tie(%h1, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; -ok $db1, "tied to SDBM_File"; +ok $db1, "tied to $db_file"; eval { $db1->Filter_Push('encode' => 'blah') }; like $@, qr/^Encoding 'blah' is not available/, "push an illigal filter" ; @@ -83,9 +93,9 @@ undef $db1; # read the dbm file without the filter my %h2 = () ; -my $db2 = tie(%h2, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; +my $db2 = tie(%h2, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; -ok $db2, "tied to SDBM_File"; +ok $db2, "tied to $db_file"; if (ord('A') == 193) { # EBCDIC. VerifyData(\%h2, diff --git a/lib/DBM_Filter/t/int32.t b/lib/DBM_Filter/t/int32.t index 5cdadde..96d4d9e 100644 --- a/lib/DBM_Filter/t/int32.t +++ b/lib/DBM_Filter/t/int32.t @@ -8,16 +8,26 @@ require "dbm_filter_util.pl"; use Test::More tests => 22; BEGIN { use_ok('DBM_Filter') }; -BEGIN { use_ok('SDBM_File') }; +my $db_file; +BEGIN { + use Config; + foreach (qw/SDBM_File ODBM_File NDBM_File GDBM_File DB_File/) { + if ($Config{extensions} =~ /\b$_\b/) { + $db_file = $_; + last; + } + } + use_ok($db_file); +}; BEGIN { use_ok('Fcntl') }; unlink ; END { unlink ; } my %h1 = () ; -my $db1 = tie(%h1, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; +my $db1 = tie(%h1, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; -ok $db1, "tied to SDBM_File"; +ok $db1, "tied to $db_file"; # store before adding the filter @@ -63,9 +73,9 @@ undef $db1; # read the dbm file without the filter my %h2 = () ; -my $db2 = tie(%h2, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; +my $db2 = tie(%h2, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; -ok $db2, "tied to SDBM_File"; +ok $db2, "tied to $db_file"; VerifyData(\%h2, { diff --git a/lib/DBM_Filter/t/null.t b/lib/DBM_Filter/t/null.t index 2d1c22a..8846183 100644 --- a/lib/DBM_Filter/t/null.t +++ b/lib/DBM_Filter/t/null.t @@ -8,16 +8,26 @@ require "dbm_filter_util.pl"; use Test::More tests => 26; BEGIN { use_ok('DBM_Filter') }; -BEGIN { use_ok('SDBM_File') }; +my $db_file; +BEGIN { + use Config; + foreach (qw/SDBM_File ODBM_File NDBM_File GDBM_File DB_File/) { + if ($Config{extensions} =~ /\b$_\b/) { + $db_file = $_; + last; + } + } + use_ok($db_file); +}; BEGIN { use_ok('Fcntl') }; unlink ; END { unlink ; } my %h1 = () ; -my $db1 = tie(%h1, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; +my $db1 = tie(%h1, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; -ok $db1, "tied to SDBM_File"; +ok $db1, "tied to $db_file"; # store before adding the filter @@ -66,9 +76,9 @@ undef $db1; # read the dbm file without the filter, check for null termination my %h2 = () ; -my $db2 = tie(%h2, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; +my $db2 = tie(%h2, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; -ok $db2, "tied to SDBM_File"; +ok $db2, "tied to $db_file"; VerifyData(\%h2, { diff --git a/lib/DBM_Filter/t/utf8.t b/lib/DBM_Filter/t/utf8.t index f884e04..0bc38f8 100644 --- a/lib/DBM_Filter/t/utf8.t +++ b/lib/DBM_Filter/t/utf8.t @@ -19,7 +19,17 @@ require "dbm_filter_util.pl"; use Test::More tests => 20; BEGIN { use_ok('DBM_Filter') }; -BEGIN { use_ok('SDBM_File') }; +my $db_file; +BEGIN { + use Config; + foreach (qw/SDBM_File ODBM_File NDBM_File GDBM_File DB_File/) { + if ($Config{extensions} =~ /\b$_\b/) { + $db_file = $_; + last; + } + } + use_ok($db_file); +}; BEGIN { use_ok('Fcntl') }; BEGIN { use_ok('charnames', qw{greek})}; @@ -29,9 +39,9 @@ unlink ; END { unlink ; } my %h1 = () ; -my $db1 = tie(%h1, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; +my $db1 = tie(%h1, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; -ok $db1, "tied to SDBM_File"; +ok $db1, "tied to $db_file"; eval { $db1->Filter_Push('utf8') }; is $@, '', "push a 'utf8' filter" ; @@ -65,9 +75,9 @@ undef $db1; # read the dbm file without the filter my %h2 = () ; -my $db2 = tie(%h2, 'SDBM_File','Op_dbmx', O_RDWR|O_CREAT, 0640) ; +my $db2 = tie(%h2, $db_file,'Op_dbmx', O_RDWR|O_CREAT, 0640) ; -ok $db2, "tied to SDBM_File"; +ok $db2, "tied to $db_file"; if (ord('A') == 193) { # EBCDIC. VerifyData(\%h2,