From: Steve Hay <SteveHay@planit.com>
Date: Mon, 10 Jan 2005 11:53:10 +0000 (+0000)
Subject: Need to close files before unlinking them on Win32
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=846e3505506e5ca6188404fe694911fd9e543b20;p=p5sagit%2Fp5-mst-13.2.git

Need to close files before unlinking them on Win32

(Various files created by test programs are left behind otherwise,
and distclean doesn't clean them up)

p4raw-id: //depot/perl@23778
---

diff --git a/lib/FileCache/t/01open.t b/lib/FileCache/t/01open.t
index fa7f5f0..75da3b2 100644
--- a/lib/FileCache/t/01open.t
+++ b/lib/FileCache/t/01open.t
@@ -20,6 +20,7 @@ print "1..1\n";
      for my $path ( @files ){
 	 cacheout $path;
 	 print $path "$path 1\n";
+	 close $path;
      }
      print "not " unless scalar map({ -f } @files) == scalar @files;
      print "ok 1\n";
diff --git a/lib/FileCache/t/04twoarg.t b/lib/FileCache/t/04twoarg.t
index a2a70be..66da971 100644
--- a/lib/FileCache/t/04twoarg.t
+++ b/lib/FileCache/t/04twoarg.t
@@ -21,4 +21,5 @@ print "1..1\n";
      seek(foo, 0, 0);
      print 'not ' unless <foo> eq "foo 44\n";
      print "ok 1\n";
+     close foo;
 }
diff --git a/lib/FileCache/t/07noimport.t b/lib/FileCache/t/07noimport.t
index 0f19ada..d2f926c 100644
--- a/lib/FileCache/t/07noimport.t
+++ b/lib/FileCache/t/07noimport.t
@@ -22,4 +22,5 @@ plan( tests => 1 );
 
     FileCache::cacheout("<", $file);
     ::ok( <$file> eq "bar" );
+    close $file;
 }
diff --git a/t/op/read.t b/t/op/read.t
index 4aaaeab..99a6216 100755
--- a/t/op/read.t
+++ b/t/op/read.t
@@ -35,7 +35,7 @@ my $has_perlio = !eval {
 
 my $tmpfile = 'Op_read.tmp';
 
-1 while unlink $tmpfile;
+END { 1 while unlink $tmpfile }
 
 my (@values, @buffers) = ('', '');
 
@@ -90,6 +90,7 @@ foreach my $value (@values) {
 		    $got = read (FH, $buffer, $length, $offset);
 		    is ($got, length $will_read, "got $what");
 		    is ($buffer, $expect, "buffer $what");
+		    close FH;
 		}
 	    }
 	}