This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Test that tempfile() in t/test.pl skips files that already exist
authorBrad Gilbert <b2gills@gmail.com>
Tue, 4 Feb 2014 16:31:46 +0000 (10:31 -0600)
committerTony Cook <tony@develop-help.com>
Thu, 13 Feb 2014 02:53:28 +0000 (13:53 +1100)
t/test_pl/tempfile.t

index dba363e..5c0e76e 100644 (file)
@@ -44,7 +44,18 @@ note("skipping the first filename because it is taken for use by _fresh_perl()")
 is( tempfile(), "${prefix}B");
 is( tempfile(), "${prefix}C");
 
-skip_files(22,'Y','Z');
+{
+    ok( open( my $fh, '>', "${prefix}D" ), 'created file with the next filename' );
+    is( tempfile(), "${prefix}E", 'properly skips files that already exist');
+
+    if( close($fh) ){
+        unlink_all("${prefix}D");
+    }else{
+        tempfile(); # allow the rest of the tests to work correctly
+    }
+}
+
+skip_files(20,'Y','Z');
 
 is( tempfile(), "${prefix}Z", 'Last single letter filename');
 is( tempfile(), "${prefix}AA", 'First double letter filename');