From: rkinyon Date: Fri, 17 Mar 2006 15:55:10 +0000 (+0000) Subject: Added unflocks to all tests so that the tests run on OSX X-Git-Tag: 0-99_01~58 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=58910373ba1f3191dc7ac6cadafc6e61de2e10be;p=dbsrgits%2FDBM-Deep.git Added unflocks to all tests so that the tests run on OSX --- diff --git a/lib/DBM/Deep/Engine.pm b/lib/DBM/Deep/Engine.pm index ad75d91..3f6a99b 100644 --- a/lib/DBM/Deep/Engine.pm +++ b/lib/DBM/Deep/Engine.pm @@ -109,7 +109,9 @@ sub setup_fh { $self->open( $obj ) if !defined $obj->_fh; my $fh = $obj->_fh; + print "1\n"; flock $fh, LOCK_EX; + print "2\n"; unless ( $obj->{base_offset} ) { seek($fh, 0 + $obj->_root->{file_offset}, SEEK_SET); diff --git a/t/01_basic.t b/t/01_basic.t index b28e389..194812d 100644 --- a/t/01_basic.t +++ b/t/01_basic.t @@ -4,6 +4,7 @@ use strict; use Test::More tests => 3; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); diag "Testing DBM::Deep against Perl $] located at $^X"; @@ -13,8 +14,12 @@ use_ok( 'DBM::Deep' ); # basic file open ## my $dir = tempdir( CLEANUP => 1 ); -my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); -my $db = eval { DBM::Deep->new( $filename ) }; +my ($fh, $filename) = tempfile( 'tmpXXXX', DIR => $dir ); +flock $fh, LOCK_UN; +my $db = eval { + local $SIG{__DIE__}; + DBM::Deep->new( $filename ); +}; if ( $@ ) { diag "ERROR: $@"; Test::More->builder->BAIL_OUT( "Opening a new file fails" ); diff --git a/t/02_hash.t b/t/02_hash.t index 6cf6079..5f772fb 100644 --- a/t/02_hash.t +++ b/t/02_hash.t @@ -5,11 +5,13 @@ use strict; use Test::More tests => 30; use Test::Exception; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my $dir = tempdir( CLEANUP => 1 ); my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh, LOCK_UN; my $db = DBM::Deep->new( $filename ); ## diff --git a/t/03_bighash.t b/t/03_bighash.t index 03d8298..e31920b 100644 --- a/t/03_bighash.t +++ b/t/03_bighash.t @@ -4,11 +4,13 @@ use strict; use Test::More tests => 2; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my $dir = tempdir( CLEANUP => 1 ); my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh, LOCK_UN; my $db = DBM::Deep->new( file => $filename, type => DBM::Deep->TYPE_HASH diff --git a/t/04_array.t b/t/04_array.t index 7a146ef..d5e5138 100644 --- a/t/04_array.t +++ b/t/04_array.t @@ -5,11 +5,13 @@ use strict; use Test::More tests => 107; use Test::Exception; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my $dir = tempdir( CLEANUP => 1 ); my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh, LOCK_UN; my $db = DBM::Deep->new( file => $filename, type => DBM::Deep->TYPE_ARRAY diff --git a/t/05_bigarray.t b/t/05_bigarray.t index e088bac..738dc68 100644 --- a/t/05_bigarray.t +++ b/t/05_bigarray.t @@ -4,11 +4,13 @@ use strict; use Test::More tests => 2; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my $dir = tempdir( CLEANUP => 1 ); my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh, LOCK_UN; my $db = DBM::Deep->new( file => $filename, type => DBM::Deep->TYPE_ARRAY diff --git a/t/06_error.t b/t/06_error.t index f36db8a..8615ba1 100644 --- a/t/06_error.t +++ b/t/06_error.t @@ -6,11 +6,13 @@ use strict; use Test::More tests => 6; use Test::Exception; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my $dir = tempdir( CLEANUP => 1 ); my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh, LOCK_UN; ## # test a corrupted file @@ -24,6 +26,7 @@ throws_ok { { my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); + flock $fh, LOCK_UN; my %hash; tie %hash, 'DBM::Deep', $filename; undef %hash; @@ -40,6 +43,7 @@ throws_ok { { my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); + flock $fh, LOCK_UN; my @array; tie @array, 'DBM::Deep', $filename; undef @array; diff --git a/t/07_locking.t b/t/07_locking.t index c6760ea..f92bb8f 100644 --- a/t/07_locking.t +++ b/t/07_locking.t @@ -4,11 +4,13 @@ use strict; use Test::More tests => 4; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my $dir = tempdir( CLEANUP => 1 ); my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh, LOCK_UN; my $db = DBM::Deep->new( file => $filename, locking => 1, diff --git a/t/08_deephash.t b/t/08_deephash.t index 59eb641..521b62d 100644 --- a/t/08_deephash.t +++ b/t/08_deephash.t @@ -4,11 +4,13 @@ use strict; use Test::More tests => 5; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my $dir = tempdir( CLEANUP => 1 ); my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh, LOCK_UN; my $max_levels = 1000; diff --git a/t/09_deeparray.t b/t/09_deeparray.t index d9ba676..749e411 100644 --- a/t/09_deeparray.t +++ b/t/09_deeparray.t @@ -4,11 +4,13 @@ use strict; use Test::More tests => 3; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my $dir = tempdir( CLEANUP => 1 ); my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh, LOCK_UN; my $max_levels = 1000; diff --git a/t/10_largekeys.t b/t/10_largekeys.t index a6964a7..32bc3f7 100644 --- a/t/10_largekeys.t +++ b/t/10_largekeys.t @@ -4,11 +4,13 @@ use strict; use Test::More tests => 14; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my $dir = tempdir( CLEANUP => 1 ); my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh, LOCK_UN; my $db = DBM::Deep->new( file => $filename, ); diff --git a/t/12_clone.t b/t/12_clone.t index 42515dd..ac3a42d 100644 --- a/t/12_clone.t +++ b/t/12_clone.t @@ -4,11 +4,13 @@ use strict; use Test::More tests => 14; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my $dir = tempdir( CLEANUP => 1 ); my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh, LOCK_UN; { my $clone; diff --git a/t/13_setpack.t b/t/13_setpack.t index b0650ab..603b6a0 100644 --- a/t/13_setpack.t +++ b/t/13_setpack.t @@ -4,6 +4,7 @@ use strict; use Test::More tests => 2; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); @@ -13,6 +14,7 @@ my ($before, $after); { my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); + flock $fh, LOCK_UN; my $db = DBM::Deep->new( file => $filename, autoflush => 1 @@ -24,6 +26,7 @@ my ($before, $after); { my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); + flock $fh, LOCK_UN; my $db = DBM::Deep->new( file => $filename, autoflush => 1 diff --git a/t/14_filter.t b/t/14_filter.t index afb556c..a74eb03 100644 --- a/t/14_filter.t +++ b/t/14_filter.t @@ -4,11 +4,13 @@ use strict; use Test::More tests => 17; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my $dir = tempdir( CLEANUP => 1 ); my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh, LOCK_UN; my $db = DBM::Deep->new( file => $filename, ); diff --git a/t/15_digest.t b/t/15_digest.t index 485052e..10c9329 100644 --- a/t/15_digest.t +++ b/t/15_digest.t @@ -4,11 +4,13 @@ use strict; use Test::More tests => 14; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my $dir = tempdir( CLEANUP => 1 ); my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh, LOCK_UN; my $salt = 38473827; diff --git a/t/16_circular.t b/t/16_circular.t index 456e1a9..8cd099e 100644 --- a/t/16_circular.t +++ b/t/16_circular.t @@ -4,11 +4,13 @@ use strict; use Test::More tests => 32; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my $dir = tempdir( CLEANUP => 1 ); my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh, LOCK_UN; my $db = DBM::Deep->new( $filename ); ## diff --git a/t/17_import.t b/t/17_import.t index e39dd08..729d702 100644 --- a/t/17_import.t +++ b/t/17_import.t @@ -4,11 +4,13 @@ use strict; use Test::More tests => 2; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my $dir = tempdir( CLEANUP => 1 ); my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh, LOCK_UN; my $db = DBM::Deep->new( $filename ); ## diff --git a/t/18_export.t b/t/18_export.t index 77d9e4f..a7127bb 100644 --- a/t/18_export.t +++ b/t/18_export.t @@ -4,6 +4,7 @@ use strict; use Test::More tests => 2; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); @@ -12,6 +13,7 @@ my $dir = tempdir( CLEANUP => 1 ); my $struct; { my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); + flock $fh, LOCK_UN; my $db = DBM::Deep->new( $filename ); ## diff --git a/t/19_crossref.t b/t/19_crossref.t index 8ce2cc0..6f6120a 100644 --- a/t/19_crossref.t +++ b/t/19_crossref.t @@ -4,15 +4,18 @@ use strict; use Test::More tests => 5; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my $dir = tempdir( CLEANUP => 1 ); my ($fh2, $filename2) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh2, LOCK_UN; my $db2 = DBM::Deep->new( $filename2 ); { my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); + flock $fh, LOCK_UN; my $db = DBM::Deep->new( $filename ); ## diff --git a/t/20_tie.t b/t/20_tie.t index 7e2e665..71acd61 100644 --- a/t/20_tie.t +++ b/t/20_tie.t @@ -5,6 +5,7 @@ use strict; use Test::More tests => 11; use Test::Exception; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); @@ -15,6 +16,7 @@ my $dir = tempdir( CLEANUP => 1 ); ## { my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); + flock $fh, LOCK_UN; my %hash; my $db = tie %hash, 'DBM::Deep', $filename; @@ -23,6 +25,7 @@ my $dir = tempdir( CLEANUP => 1 ); { my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); + flock $fh, LOCK_UN; my %hash; my $db = tie %hash, 'DBM::Deep', { file => $filename, @@ -33,6 +36,7 @@ my $dir = tempdir( CLEANUP => 1 ); { my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); + flock $fh, LOCK_UN; my @array; my $db = tie @array, 'DBM::Deep', $filename; @@ -43,6 +47,7 @@ my $dir = tempdir( CLEANUP => 1 ); { my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); + flock $fh, LOCK_UN; my @array; my $db = tie @array, 'DBM::Deep', { file => $filename, @@ -54,6 +59,7 @@ my $dir = tempdir( CLEANUP => 1 ); } my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh, LOCK_UN; throws_ok { tie my %hash, 'DBM::Deep', [ file => $filename ]; } qr/Not a hashref/, "Passing an arrayref to TIEHASH fails"; diff --git a/t/21_tie_access.t b/t/21_tie_access.t index d911788..42d1fbe 100644 --- a/t/21_tie_access.t +++ b/t/21_tie_access.t @@ -5,11 +5,13 @@ use strict; use Test::More tests => 7; use Test::Exception; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my $dir = tempdir(); my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh, LOCK_UN; { my %hash; @@ -40,6 +42,7 @@ my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); { my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); + flock $fh, LOCK_UN; DBM::Deep->new( file => $filename, type => DBM::Deep->TYPE_ARRAY ); throws_ok { diff --git a/t/22_internal_copy.t b/t/22_internal_copy.t index e75ac0c..699f6c0 100644 --- a/t/22_internal_copy.t +++ b/t/22_internal_copy.t @@ -4,11 +4,13 @@ use strict; use Test::More tests => 13; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my $dir = tempdir( CLEANUP => 1 ); my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh, LOCK_UN; my $db = DBM::Deep->new( $filename ); ## @@ -50,6 +52,7 @@ is( $db->{copy}{subkey3}, 'subvalue3', "After the second copy, we're still good" my $max_keys = 1000; my ($fh2, $filename2) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh2, LOCK_UN; { my $db = DBM::Deep->new( $filename2 ); diff --git a/t/23_misc.t b/t/23_misc.t index f02193d..5b42189 100644 --- a/t/23_misc.t +++ b/t/23_misc.t @@ -5,11 +5,13 @@ use strict; use Test::More tests => 7; use Test::Exception; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my $dir = tempdir( CLEANUP => 1 ); my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh, LOCK_UN; my $db = DBM::Deep->new( $filename ); $db->{key1} = "value1"; diff --git a/t/24_autobless.t b/t/24_autobless.t index 42b0d01..57f7d92 100644 --- a/t/24_autobless.t +++ b/t/24_autobless.t @@ -9,11 +9,13 @@ use strict; use Test::More tests => 64; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my $dir = tempdir( CLEANUP => 1 ); my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh, LOCK_UN; { my $db = DBM::Deep->new( file => $filename, @@ -149,6 +151,7 @@ my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); } my ($fh2, $filename2) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh2, LOCK_UN; { my $db = DBM::Deep->new( file => $filename2, @@ -180,6 +183,7 @@ my ($fh2, $filename2) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); # content after that point in file to check for corruption. ## my ($fh3, $filename3) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); + flock $fh3, LOCK_UN; my $db = DBM::Deep->new( file => $filename3, autobless => 1, diff --git a/t/25_tie_return_value.t b/t/25_tie_return_value.t index 4e3c676..e14c319 100644 --- a/t/25_tie_return_value.t +++ b/t/25_tie_return_value.t @@ -2,6 +2,7 @@ use strict; use Test::More tests => 5; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); @@ -11,6 +12,7 @@ use Scalar::Util qw( reftype ); { my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); + flock $fh, LOCK_UN; my %hash; my $obj = tie %hash, 'DBM::Deep', $filename; @@ -20,6 +22,7 @@ use Scalar::Util qw( reftype ); { my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); + flock $fh, LOCK_UN; my @array; my $obj = tie @array, 'DBM::Deep', $filename; diff --git a/t/26_scalar_ref.t b/t/26_scalar_ref.t index 7a77c39..06beda8 100644 --- a/t/26_scalar_ref.t +++ b/t/26_scalar_ref.t @@ -3,11 +3,13 @@ use strict; use Test::More tests => 10; use Test::Exception; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my $dir = tempdir( CLEANUP => 1 ); my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh, LOCK_UN; my $x = 25; { diff --git a/t/27_filehandle.t b/t/27_filehandle.t index 2c4d04e..6ec27d1 100644 --- a/t/27_filehandle.t +++ b/t/27_filehandle.t @@ -5,11 +5,13 @@ use strict; use Test::More tests => 11; use Test::Exception; use File::Temp qw( tempfile tempdir ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my $dir = tempdir( CLEANUP => 1 ); my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1, DIR => $dir ); +flock $fh, LOCK_UN; # Create the datafile to be used { diff --git a/t/29_freespace_manager.t b/t/29_freespace_manager.t index d6b18fb..abf5683 100644 --- a/t/29_freespace_manager.t +++ b/t/29_freespace_manager.t @@ -2,10 +2,12 @@ use strict; use Test::More tests => 3; use File::Temp qw( tempfile ); +use Fcntl qw( :flock ); use_ok( 'DBM::Deep' ); my ($fh, $filename) = tempfile( 'tmpXXXX', UNLINK => 1 ); +flock $fh, LOCK_UN; my $db = DBM::Deep->new({ file => $filename, autoflush => 1,