summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Hay <SteveHay@planit.com>2005-07-25 11:11:29 +0000
committerSteve Hay <SteveHay@planit.com>2005-07-25 11:11:29 +0000
commitda2b6f3329c3a764a9e5a8032aebe3c69d3f55c4 (patch)
tree42190b702d356c7eb7e96706974062f2ef224680
parent73f04f90b60fd44a3d3f40a0f6f5c565ad2f221a (diff)
downloadperl-da2b6f3329c3a764a9e5a8032aebe3c69d3f55c4.tar.gz
Make CBuilder and ParseXS clean up their temp test files
p4raw-id: //depot/perl@25222
-rw-r--r--lib/ExtUtils/CBuilder.pm2
-rw-r--r--lib/ExtUtils/CBuilder/Base.pm16
-rw-r--r--lib/ExtUtils/CBuilder/t/01-basic.t5
-rw-r--r--lib/ExtUtils/CBuilder/t/02-link.t5
-rw-r--r--lib/ExtUtils/ParseXS.pm2
-rw-r--r--lib/ExtUtils/ParseXS/t/basic.t24
6 files changed, 39 insertions, 15 deletions
diff --git a/lib/ExtUtils/CBuilder.pm b/lib/ExtUtils/CBuilder.pm
index f2950aafbd..9100bc78d4 100644
--- a/lib/ExtUtils/CBuilder.pm
+++ b/lib/ExtUtils/CBuilder.pm
@@ -5,7 +5,7 @@ use File::Path ();
use File::Basename ();
use vars qw($VERSION @ISA);
-$VERSION = '0.12';
+$VERSION = '0.12_01';
$VERSION = eval $VERSION;
# Okay, this is the brute-force method of finding out what kind of
diff --git a/lib/ExtUtils/CBuilder/Base.pm b/lib/ExtUtils/CBuilder/Base.pm
index 68a9f4150d..774bb46f9e 100644
--- a/lib/ExtUtils/CBuilder/Base.pm
+++ b/lib/ExtUtils/CBuilder/Base.pm
@@ -32,7 +32,16 @@ sub find_perl_interpreter {
sub add_to_cleanup {
my $self = shift;
- my %files = map {$_, 1} @_;
+ foreach (@_) {
+ $self->{files_to_clean}{$_} = 1;
+ }
+}
+
+sub cleanup {
+ my $self = shift;
+ foreach my $file (keys %{$self->{files_to_clean}}) {
+ unlink $file;
+ }
}
sub object_file {
@@ -246,4 +255,9 @@ sub perl_inc {
$self->perl_src() || File::Spec->catdir($self->{config}{archlibexp},"CORE");
}
+sub DESTROY {
+ my $self = shift;
+ $self->cleanup();
+}
+
1;
diff --git a/lib/ExtUtils/CBuilder/t/01-basic.t b/lib/ExtUtils/CBuilder/t/01-basic.t
index 7e4b32262e..b13f4d0bdc 100644
--- a/lib/ExtUtils/CBuilder/t/01-basic.t
+++ b/lib/ExtUtils/CBuilder/t/01-basic.t
@@ -47,10 +47,7 @@ my ($lib, @temps) = $b->link(objects => $object_file,
$lib =~ tr/"'//d;
ok $lib_file, $lib;
-for ($source_file, $lib_file, $object_file, @temps) {
- tr/"'//d;
- 1 while unlink;
-}
+unlink $source_file;
my @words = $b->split_like_shell(' foo bar');
ok @words, 2;
diff --git a/lib/ExtUtils/CBuilder/t/02-link.t b/lib/ExtUtils/CBuilder/t/02-link.t
index db9a1c36ff..ccfe4ee182 100644
--- a/lib/ExtUtils/CBuilder/t/02-link.t
+++ b/lib/ExtUtils/CBuilder/t/02-link.t
@@ -55,10 +55,7 @@ ok $exe_file;
ok my_system($exe_file), 11;
# Clean up
-for ($source_file, $exe_file, $object_file, @temps) {
- tr/"'//d;
- 1 while unlink;
-}
+unlink $source_file;
sub my_system {
my $cmd = shift;
diff --git a/lib/ExtUtils/ParseXS.pm b/lib/ExtUtils/ParseXS.pm
index 3e6e8739ab..fb2c7aad78 100644
--- a/lib/ExtUtils/ParseXS.pm
+++ b/lib/ExtUtils/ParseXS.pm
@@ -17,7 +17,7 @@ my(@XSStack); # Stack of conditionals and INCLUDEs
my($XSS_work_idx, $cpp_next_tmp);
use vars qw($VERSION);
-$VERSION = '2.10';
+$VERSION = '2.11_01';
use vars qw(%input_expr %output_expr $ProtoUsed @InitFileCode $FH $proto_re $Overload $errors $Fallback
$cplusplus $hiertype $WantPrototypes $WantVersionChk $except $WantLineNumbers
diff --git a/lib/ExtUtils/ParseXS/t/basic.t b/lib/ExtUtils/ParseXS/t/basic.t
index 6aeec44f2a..efaf968434 100644
--- a/lib/ExtUtils/ParseXS/t/basic.t
+++ b/lib/ExtUtils/ParseXS/t/basic.t
@@ -11,6 +11,7 @@ BEGIN {
use strict;
use Test;
BEGIN { plan tests => 10 };
+use DynaLoader;
use ExtUtils::ParseXS qw(process_file);
use ExtUtils::CBuilder;
ok(1); # If we made it this far, we're loaded.
@@ -26,9 +27,11 @@ tie *FH, 'Foo';
process_file( filename => 'XSTest.xs', output => \*FH, prototypes => 1 );
ok tied(*FH)->content, '/is_even/', "Test that output contains some text";
+my $source_file = 'XSTest.c';
+
# Try sending to file
-process_file( filename => 'XSTest.xs', output => 'XSTest.c', prototypes => 0 );
-ok -e 'XSTest.c', 1, "Create an output file";
+process_file(filename => 'XSTest.xs', output => $source_file, prototypes => 0);
+ok -e $source_file, 1, "Create an output file";
# TEST doesn't like extraneous output
my $quiet = $ENV{PERL_CORE} && !$ENV{HARNESS_ACTIVE};
@@ -38,7 +41,7 @@ my $b = ExtUtils::CBuilder->new(quiet => $quiet);
if ($b->have_compiler) {
my $module = 'XSTest';
- my $obj_file = $b->compile( source => "$module.c" );
+ my $obj_file = $b->compile( source => $source_file );
ok $obj_file;
ok -e $obj_file, 1, "Make sure $obj_file exists";
@@ -51,10 +54,23 @@ if ($b->have_compiler) {
ok XSTest::is_even(8);
ok !XSTest::is_even(9);
+ # Win32 needs to close the DLL before it can unlink it, but unfortunately
+ # dl_unload_file was missing on Win32 prior to perl change #24679!
+ if ($^O eq 'MSWin32' and defined &DynaLoader::dl_unload_file) {
+ for (my $i = 0; $i < @DynaLoader::dl_modules; $i++) {
+ if ($DynaLoader::dl_modules[$i] eq $module) {
+ DynaLoader::dl_unload_file($DynaLoader::dl_librefs[$i]);
+ last;
+ }
+ }
+ }
+ unlink $lib_file;
} else {
- skip "Skipped can't find a C compiler & linker", 1 for 1..6;
+ skip "Skipped can't find a C compiler & linker", 1 for 1..7;
}
+unlink $source_file;
+
#####################################################################
sub Foo::TIEHANDLE { bless {}, 'Foo' }