Added a comment as to where an allocation error is occurring that crashes perl
[dbsrgits/DBM-Deep.git] / t / common.pm
1 package # Hide from PAUSE
2     t::common;
3
4 use 5.006_000;
5
6 use strict;
7 use warnings;
8
9 our $VERSION = '0.01';
10
11 use base 'Exporter';
12 our @EXPORT_OK = qw(
13     new_fh
14 );
15
16 use File::Spec ();
17 use File::Temp qw( tempfile tempdir );
18 use Fcntl qw( :flock );
19
20 my $parent = $ENV{WORK_DIR} || File::Spec->tmpdir;
21 my $dir = tempdir( CLEANUP => 1, DIR => $parent );
22 #my $dir = tempdir( DIR => '.' );
23
24 sub new_fh {
25     my ($fh, $filename) = tempfile( 'tmpXXXX', DIR => $dir, UNLINK => 1 );
26
27     # This is because tempfile() returns a flock'ed $fh on MacOSX.
28     flock $fh, LOCK_UN;
29
30     return ($fh, $filename);
31 }
32
33 1;
34 __END__