r14213@rob-kinyons-computer (orig r8080): rkinyon | 2006-11-17 20:47:50 -0500
[dbsrgits/DBM-Deep.git] / t / common.pm
CommitLineData
fde3db1a 1package t::common;
2
2120a181 3use 5.006_000;
fde3db1a 4
5use strict;
6use warnings;
7
8our $VERSION = '0.01';
9
10use base 'Exporter';
11our @EXPORT_OK = qw(
12 new_fh
13);
14
15use File::Spec ();
16use File::Temp qw( tempfile tempdir );
17use Fcntl qw( :flock );
18
19my $parent = $ENV{WORK_DIR} || File::Spec->tmpdir;
20my $dir = tempdir( CLEANUP => 1, DIR => $parent );
21
22sub new_fh {
23 my ($fh, $filename) = tempfile( 'tmpXXXX', DIR => $dir );
24
25 # This is because tempfile() returns a flock'ed $fh on MacOSX.
26 flock $fh, LOCK_UN;
27
28 return ($fh, $filename);
29}
30#END{<>}
311;
32__END__
33