Author: dagolden
Date: Sat Jan 17 08:51:32 2009
New Revision: 12453
Modified:
Module-Build/trunk/ (props changed)
Module-Build/trunk/Build.PL
Module-Build/trunk/Changes
Module-Build/trunk/t/ext.t
Module-Build/trunk/t/files.t
Module-Build/trunk/t/lib/MBTest.pm
Log:
make tests use File::Temp::tempdir
Modified: Module-Build/trunk/Build.PL
==============================================================================
--- Module-Build/trunk/Build.PL (original)
+++ Module-Build/trunk/Build.PL Sat Jan 17 08:51:32 2009
@@ -21,6 +21,7 @@
module_name => 'Module::Build',
license => 'perl',
build_requires => {
+ 'File::Temp' => 0.15, # tmpdir() + fixes
'Test::More' => 0.49,
'Test::Harness' => 2.03, # when TODO tests worked
},
Modified: Module-Build/trunk/Changes
==============================================================================
--- Module-Build/trunk/Changes (original)
+++ Module-Build/trunk/Changes Sat Jan 17 08:51:32 2009
@@ -1,5 +1,9 @@
Revision history for Perl extension Module::Build.
+ Other
+ - tests now use File::Temp (added to build_requires); appears to fix
+ Win32 testing heisenbug on directory removal
+
0.31_02
Compat
Modified: Module-Build/trunk/t/ext.t
==============================================================================
--- Module-Build/trunk/t/ext.t (original)
+++ Module-Build/trunk/t/ext.t Sat Jan 17 08:51:32 2009
@@ -136,12 +136,10 @@
{
# Make sure run_perl_script() propagates @INC
- my $dir = 'whosiewhatzit';
- mkdir $dir, 0777;
+ my $dir = MBTest->tmpdir;
local @INC = ($dir, @INC);
my $output = stdout_of( sub { Module::Build->run_perl_script('-le', [],
['print for @INC']) } );
- like $output, qr{^$dir}m;
- rmdir $dir;
+ like $output, qr{^\Q$dir\E}m;
}
##################################################################
Modified: Module-Build/trunk/t/files.t
==============================================================================
--- Module-Build/trunk/t/files.t (original)
+++ Module-Build/trunk/t/files.t Sat Jan 17 08:51:32 2009
@@ -16,8 +16,6 @@
$dist->chdir_in;
-
-
my $mb = Module::Build->new_from_context;
my @files;
@@ -25,27 +23,18 @@
# Make sure copy_if_modified() can handle spaces in filenames
my @tmp;
- foreach (1..2) {
- my $tmp = File::Spec->catdir('t', "tmp$_");
- $mb->add_to_cleanup($tmp);
- push @files, $tmp;
- unless (-d $tmp) {
- mkdir($tmp, 0777) or die "Can't create $tmp: $!";
- }
- ok -d $tmp;
- $tmp[$_] = $tmp;
- }
+ push @tmp, MBTest->tmpdir for (0 .. 1);
my $filename = 'file with spaces.txt';
- my $file = File::Spec->catfile($tmp[1], $filename);
+ my $file = File::Spec->catfile($tmp[0], $filename);
my $fh = IO::File->new($file, '>') or die "Can't create $file: $!";
print $fh "Foo\n";
$fh->close;
ok -e $file;
- my $file2 = $mb->copy_if_modified(from => $file, to_dir => $tmp[2]);
+ my $file2 = $mb->copy_if_modified(from => $file, to_dir => $tmp[1]);
ok $file2;
ok -e $file2;
}
Modified: Module-Build/trunk/t/lib/MBTest.pm
==============================================================================
--- Module-Build/trunk/t/lib/MBTest.pm (original)
+++ Module-Build/trunk/t/lib/MBTest.pm Sat Jan 17 08:51:32 2009
@@ -3,6 +3,7 @@
use strict;
use File::Spec;
+use File::Temp ();
use File::Path ();
@@ -100,18 +101,13 @@
########################################################################
-{ # Setup a temp directory if it doesn't exist
+# always return to the current directory
+{
my $cwd = Cwd::cwd;
- my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' . $$);
- mkdir $tmp, 0777 unless -d $tmp;
- sub tmpdir { $tmp }
END {
- if(-d $tmp) {
- # Go back to where you came from!
- chdir $cwd or die "Couldn't chdir to $cwd";
- File::Path::rmtree($tmp) or diag "cannot clean dir '$tmp'";
- }
+ # Go back to where you came from!
+ chdir $cwd or die "Couldn't chdir to $cwd";
}
}
########################################################################
@@ -125,6 +121,13 @@
}
########################################################################
+# Setup a temp directory
+sub tmpdir {
+ return File::Temp::tempdir( 'MB-XXXXXXXX',
+ CLEANUP => 1, DIR => File::Spec->tmpdir
+ );
+}
+
sub save_handle {
my ($handle, $subr) = @_;
my $outfile = temp_file_name();