r11687@rob-kinyons-powerbook58: rob | 2006-04-29 23:33:57 -0400
[dbsrgits/DBM-Deep.git] / t / common.pm
CommitLineData
fde3db1a 1package t::common;
2
3use 5.6.0;
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