Convert all unimaginative (ie race condition) temporary file names to
[p5sagit/p5-mst-13.2.git] / t / io / read.t
index ea2672d..57e671d 100755 (executable)
@@ -1,7 +1,5 @@
 #!./perl
 
-# $RCSfile$
-
 BEGIN {
     chdir 't' if -d 't';
     @INC = '../lib';
@@ -9,11 +7,14 @@ BEGIN {
 }
 
 use strict;
-use Errno;
+eval 'use Errno';
+die $@ if $@ and !$ENV{PERL_CORE_MINITEST};
 
 plan tests => 2;
 
-open(A,"+>a");
+my $tmpfile = tempfile();
+
+open(A,"+>$tmpfile");
 print A "_";
 seek(A,0,0);
 
@@ -24,16 +25,13 @@ read(A,$b,1,4);
 
 close(A);
 
-unlink("a");
-
 is($b,"\000\000\000\000_"); # otherwise probably "\000bcd_"
 
-unlink 'a';
-
 SKIP: {
     skip "no EBADF", 1 if (!exists &Errno::EBADF);
 
     $! = 0;
+    no warnings 'unopened';
     read(B,$b,1);
     ok($! == &Errno::EBADF);
 }