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