[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

[PATCH] Don't reuse temp files in tests



I've been getting build failures of the form:

lib/charnames...................................Could not open
tmp154448B: Permission denied at ../lib/charnames.t line 288, <DATA>
line 1.
FAILED--expected 76 tests, saw 64

This come from the test file reusing a single temp file for each of
the program tests it's running.  Evidently, the OS is not releasing
"its hold" on the file by the time the test file loops around for the
next test.

The attached patch causes the test file to use a different temp file
for each test.  Temp file cleanup is relegated to the END block in
test.pl where the temp file names are generated.

This patch affects lib/charnames.t, lib/strict.t and lib/subs.t (which
were affected by change 34328).
--- perl-current/lib/charnames.t
+++ perl-current/lib/charnames.t
@@ -271,10 +271,8 @@
 
 # ---- Alias extensions
 
-my $tmpfile = tempfile();
 my $alifile = File::Spec->catfile(File::Spec->updir, qw(lib unicore xyzzy_alias.pl));
 my $i = 0;
-END { if ($tmpfile) { 1 while unlink $tmpfile; } }
 
 my @prgs;
 {   local $/ = undef;
@@ -285,6 +283,7 @@
 for (@prgs) {
     my ($code, $exp) = ((split m/\nEXPECT\n/), '$');
     my ($prog, $fil) = ((split m/\nFILE\n/, $code), "");
+    my $tmpfile = tempfile();
     open my $tmp, "> $tmpfile" or die "Could not open $tmpfile: $!";
     print $tmp $prog, "\n";
     close $tmp or die "Could not close $tmpfile: $!";
@@ -322,7 +321,6 @@
         print "not ";
 	}
     print "ok ", ++$i, "\n";
-    1 while unlink $tmpfile;
     $fil or next;
     1 while unlink $alifile;
     }
--- perl-current/lib/strict.t
+++ perl-current/lib/strict.t
@@ -12,9 +12,7 @@
 my $Is_VMS = $^O eq 'VMS';
 my $Is_MSWin32 = $^O eq 'MSWin32';
 my $Is_NetWare = $^O eq 'NetWare';
-my $tmpfile = tempfile();
 my $i = 0 ;
-END { if ($tmpfile) { 1 while unlink $tmpfile; } }
 
 my @prgs = () ;
 
@@ -65,6 +63,7 @@
 	$prog = shift @files ;
 	$prog =~ s|\./abc|:abc|g if $^O eq 'MacOS';
     }
+    my $tmpfile = tempfile();
     open TEST, ">$tmpfile" or die "Could not open: $!";
     print TEST $prog,"\n";
     close TEST or die "Could not close: $!";
--- perl-current/lib/subs.t
+++ perl-current/lib/subs.t
@@ -16,9 +16,7 @@
 my $Is_MSWin32 = $^O eq 'MSWin32';
 my $Is_NetWare = $^O eq 'NetWare';
 my $Is_MacOS = $^O eq 'MacOS';
-my $tmpfile = tempfile();
 my $i = 0 ;
-END {  if ($tmpfile) { 1 while unlink $tmpfile} }
 
 for (@prgs){
     my $switch = "";
@@ -44,6 +42,7 @@
 	shift @files ;
 	$prog = shift @files ;
     }
+    my $tmpfile = tempfile();
     open TEST, ">$tmpfile";
     print TEST $prog,"\n";
     close TEST;

Follow-Ups from:
Nicholas Clark <nick@ccl4.org>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]