This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Tie::File: use unique tmp filenames in test files
authorDavid Mitchell <davem@iabyn.com>
Mon, 13 Jan 2020 14:04:38 +0000 (14:04 +0000)
committerDavid Mitchell <davem@iabyn.com>
Mon, 13 Jan 2020 14:04:38 +0000 (14:04 +0000)
Currently all the test scripts use a temporary file of the form
"tf$$.txt", which could possibly cause clashes between test scripts
on platforms where the PID cycles frequently. This commit gives each
test file its own unique tmp-filename prefix, e.g. 42_offset.t now has

    my $file = "tf42-$$.txt";

I probably should have switched over completely to using File::Temp,
but this was a smaller change, and I haven't tested it on older perls.

The motivation for this is occasional test failures of 29a_upcopy.t on
some smokes. Whether this commit fixes that, only time will tell.

35 files changed:
dist/Tie-File/t/01_gen.t
dist/Tie-File/t/02_fetchsize.t
dist/Tie-File/t/03_longfetch.t
dist/Tie-File/t/04_splice.t
dist/Tie-File/t/05_size.t
dist/Tie-File/t/06_fixrec.t
dist/Tie-File/t/07_rv_splice.t
dist/Tie-File/t/08_ro.t
dist/Tie-File/t/09_gen_rs.t
dist/Tie-File/t/10_splice_rs.t
dist/Tie-File/t/11_rv_splice_rs.t
dist/Tie-File/t/12_longfetch_rs.t
dist/Tie-File/t/13_size_rs.t
dist/Tie-File/t/14_lock.t
dist/Tie-File/t/15_pushpop.t
dist/Tie-File/t/16_handle.t
dist/Tie-File/t/17_misc_meth.t
dist/Tie-File/t/18_rs_fixrec.t
dist/Tie-File/t/19_cache.t
dist/Tie-File/t/20_cache_full.t
dist/Tie-File/t/21_win32.t
dist/Tie-File/t/22_autochomp.t
dist/Tie-File/t/23_rv_ac_splice.t
dist/Tie-File/t/24_cache_loop.t
dist/Tie-File/t/25_gen_nocache.t
dist/Tie-File/t/26_twrite.t
dist/Tie-File/t/27_iwrite.t
dist/Tie-File/t/28_mtwrite.t
dist/Tie-File/t/29_downcopy.t
dist/Tie-File/t/29a_upcopy.t
dist/Tie-File/t/30_defer.t
dist/Tie-File/t/31_autodefer.t
dist/Tie-File/t/32_defer_misc.t
dist/Tie-File/t/33_defer_vs.t
dist/Tie-File/t/42_offset.t

index e9504d3..3c4aefc 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 
 $| = 1;
-my $file = "tf$$.txt";
+my $file = "tf01-$$.txt";
 1 while unlink $file;
 
 print "1..75\n";
index 146a91a..cfaf9ce 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-my $file = "tf$$.txt";
+my $file = "tf02-$$.txt";
 $: = Tie::File::_default_recsep();
 my $data = "rec1$:rec2$:rec3$:";
 
index 63dad4f..cc6aa02 100644 (file)
@@ -8,7 +8,7 @@
 # (tests _fill_offsets_to() )
 #
 
-my $file = "tf$$.txt";
+my $file = "tf03-$$.txt";
 $: = Tie::File::_default_recsep();
 my $data = "rec0$:rec1$:rec2$:";
 
index 8d23c58..3577ecf 100644 (file)
@@ -13,7 +13,7 @@
 
 
 $| = 1;
-my $file = "tf$$.txt";
+my $file = "tf04-$$.txt";
 $: = Tie::File::_default_recsep();
 my $data = "rec0$:rec1$:rec2$:";
 print "1..118\n";
index 72774c8..74a75be 100644 (file)
@@ -6,7 +6,7 @@
 
 use POSIX 'SEEK_SET';
 
-my $file = "tf$$.txt";
+my $file = "tf05-$$.txt";
 my ($o, $n);
 
 print "1..16\n";
index bf24be1..50817ca 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 
 use POSIX 'SEEK_SET';
-my $file = "tf$$.txt";
+my $file = "tf06-$$.txt";
 $: = Tie::File::_default_recsep();
 
 print "1..5\n";
index 141383a..6d0efa8 100644 (file)
@@ -5,7 +5,7 @@
 #
 
 
-my $file = "tf$$.txt";
+my $file = "tf07-$$.txt";
 $: = Tie::File::_default_recsep();
 my $data = "rec0$:rec1$:rec2$:";
 
index a38e7fa..bf6a316 100644 (file)
@@ -3,7 +3,7 @@
 # Make sure it works to open the file in read-only mode
 #
 
-my $file = "tf$$.txt";
+my $file = "tf08-$$.txt";
 $: = Tie::File::_default_recsep();
 
 print "1..13\n";
index 88d8250..272dada 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-my $file = "tf$$.txt";
+my $file = "tf09-$$.txt";
 
 print "1..59\n";
 
index da981db..24e81cd 100644 (file)
@@ -12,7 +12,7 @@
 
 use POSIX 'SEEK_SET';
 
-my $file = "tf$$.txt";
+my $file = "tf10-$$.txt";
 my $data = "rec0blahrec1blahrec2blah";
 
 print "1..101\n";
index 2fc9f2c..fd89d83 100644 (file)
@@ -4,7 +4,7 @@
 # (04_splice.t checks its effect on the file)
 #
 
-my $file = "tf$$.txt";
+my $file = "tf11-$$.txt";
 my $data = "rec0blahrec1blahrec2blah";
 
 print "1..50\n";
index 4e5d57b..8f3e79b 100644 (file)
@@ -6,7 +6,7 @@
 # (tests _fill_offsets_to() )
 #
 
-my $file = "tf$$.txt";
+my $file = "tf12-$$.txt";
 my $data = "rec0blahrec1blahrec2blah";
 
 print "1..5\n";
index b2e534c..4e4a268 100644 (file)
@@ -6,7 +6,7 @@
 
 use POSIX 'SEEK_SET';
 
-my $file = "tf$$.txt";
+my $file = "tf13-$$.txt";
 my $data = "rec0blahrec1blahrec2blah";
 my ($o, $n);
 
index c523458..1979a0e 100644 (file)
@@ -18,7 +18,7 @@ BEGIN {
 
 use Fcntl ':flock';             # This works at least back to 5.004_04
 
-my $file = "tf$$.txt";
+my $file = "tf14-$$.txt";
 my ($o, $n);
 my @a;
 
index 4b6d1bc..ecf4a06 100644 (file)
@@ -11,7 +11,7 @@
 
 use POSIX 'SEEK_SET';
 
-my $file = "tf$$.txt";
+my $file = "tf15-$$.txt";
 1 while unlink $file;
 $: = Tie::File::_default_recsep();
 my $data = "rec0$:rec1$:rec2$:";
index 21a3fce..2c9456f 100644 (file)
@@ -3,7 +3,7 @@
 # Basic operation, initializing the object from an already-open handle
 # instead of from a filename
 
-my $file = "tf$$.txt";
+my $file = "tf16-$$.txt";
 $: = Tie::File::_default_recsep();
 
 if ($^O =~ /vms/i) {
index 020774b..1eaec2c 100644 (file)
@@ -4,7 +4,7 @@
 # EXTEND, CLEAR, DELETE, EXISTS
 #
 
-my $file = "tf$$.txt";
+my $file = "tf17-$$.txt";
 $: = Tie::File::_default_recsep();
 1 while unlink $file;
 
index 3c2a807..4e307bd 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 
 use POSIX 'SEEK_SET';
-my $file = "tf$$.txt";
+my $file = "tf18-$$.txt";
 $/ = "blah";
 
 print "1..5\n";
index a8b6e69..cfb44ab 100644 (file)
@@ -4,7 +4,7 @@
 #
 
 $|=1;
-my $file = "tf$$.txt";
+my $file = "tf19-$$.txt";
 $: = Tie::File::_default_recsep();
 my $data = join $:, "rec0" .. "rec9", "";
 my $V = $ENV{INTEGRITY};        # Verbose integrity checking?
index bd4d6a7..b9dd6dc 100644 (file)
@@ -3,7 +3,7 @@
 # Tests for various caching errors
 #
 
-my $file = "tf$$.txt";
+my $file = "tf20-$$.txt";
 $: = Tie::File::_default_recsep();
 my $data = join $:, "record0" .. "record9", "";
 my $V = $ENV{INTEGRITY};        # Verbose integrity checking?
index 0ccf669..cabb93b 100644 (file)
@@ -7,7 +7,7 @@
 #
 # These tests (Win32 only) make sure that the file had \r\n as it should.
 
-my $file = "tf$$.txt";
+my $file = "tf21-$$.txt";
 
 unless ($^O =~ /^(MSWin32|dos)$/) {
   print "1..0\n";
index ebf3eac..18b9461 100644 (file)
@@ -1,6 +1,6 @@
 #!/usr/bin/perl
 
-my $file = "tf$$.txt";
+my $file = "tf22-$$.txt";
 $: = Tie::File::_default_recsep();
 
 print "1..71\n";
index 104045a..fe066e7 100644 (file)
@@ -4,7 +4,7 @@
 # (07_rv_splice.t checks it aith autochomping off)
 #
 
-my $file = "tf$$.txt";
+my $file = "tf23-$$.txt";
 $: = Tie::File::_default_recsep();
 my $data = "rec0$:rec1$:rec2$:";
 
index 42c002c..a6a20bb 100644 (file)
@@ -4,7 +4,7 @@
 #
 
 use Config;
-my $file = "tf$$.txt";
+my $file = "tf24-$$.txt";
 unless ($Config{d_alarm}) {
   print "1..0\n"; exit;
 }
index ce55d27..9dacf6b 100644 (file)
@@ -3,7 +3,7 @@
 # Regular read-write tests with caching disabled
 # (Same as 01_gen.t)
 #
-my $file = "tf$$.txt";
+my $file = "tf25-$$.txt";
 
 print "1..68\n";
 
index d827f1c..2125223 100644 (file)
@@ -11,7 +11,7 @@
 # $len == 0 is a pure insert; $len == length($data) is a simple overwrite.
 #
 
-my $file = "tf$$.txt";
+my $file = "tf26-$$.txt";
 
 print "1..181\n";
 
index 04ad436..cada89b 100644 (file)
@@ -11,7 +11,7 @@
 # (Because we inserted $data at the beginning) we copy as much as possible
 # and return a string containing the remainder.
 
-my $file = "tf$$.txt";
+my $file = "tf27-$$.txt";
 $| = 1;
 
 print "1..203\n";
index 3146369..8d437e6 100644 (file)
@@ -7,7 +7,7 @@
 # 'm' here is for 'multiple'.  This writes data $d1 at position $s1
 # over a block of space $l1, moving subsequent data up or down as necessary.
 
-my $file = "tf$$.txt";
+my $file = "tf28-$$.txt";
 $| = 1;
 
 print "1..2252\n";
index 793116a..a85cd69 100644 (file)
@@ -10,7 +10,7 @@
 #
 #
 
-my $file = "tf$$.txt";
+my $file = "tf29-$$.txt";
 
 print "1..718\n";
 
index 9840af4..f23fa47 100644 (file)
@@ -10,7 +10,7 @@
 # but the source and destination regions may overlap.)
 
 
-my $file = "tf$$.txt";
+my $file = "tf29-$$.txt";
 
 print "1..55\n";
 
index 975cdfb..78a5265 100644 (file)
@@ -8,7 +8,7 @@
 #
 
 use POSIX 'SEEK_SET';
-my $file = "tf$$.txt";
+my $file = "tf30-$$.txt";
 $: = Tie::File::_default_recsep();
 my $data = "rec0$:rec1$:rec2$:";
 my ($o, $n);
index baf72c2..41d2514 100644 (file)
@@ -8,7 +8,7 @@
 
 use POSIX 'SEEK_SET';
 
-my $file = "tf$$.txt";
+my $file = "tf31-$$.txt";
 $: = Tie::File::_default_recsep();
 my $data = "rec0$:rec1$:rec2$:";
 my ($o, $n, @a);
index f4ee110..ca81c7c 100644 (file)
@@ -6,7 +6,7 @@
 #
 
 use POSIX 'SEEK_SET';
-my $file = "tf$$.txt";
+my $file = "tf32-$$.txt";
 $: = Tie::File::_default_recsep();
 my $data = "rec0$:rec1$:rec2$:";
 my ($o, $n);
index b68541c..b7f01ce 100644 (file)
@@ -9,7 +9,7 @@
 #
 
 use POSIX 'SEEK_SET';
-my $file = "tf$$.txt";
+my $file = "tf33-$$.txt";
 # print "1..0\n"; exit;
 $: = Tie::File::_default_recsep();
 my $data = "$:1$:22$:";
index 8c62832..5aa20bf 100644 (file)
@@ -7,7 +7,7 @@ use strict;
 use File::Spec;
 
 use POSIX 'SEEK_SET';
-my $file = "tf$$.txt";
+my $file = "tf42-$$.txt";
 
 BEGIN
   {