summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-08-06 16:04:49 +0000
committerNicholas Clark <nick@ccl4.org>2008-08-06 16:04:49 +0000
commit7a7e49369367a634141dd279a31cb8e210734b24 (patch)
tree23e68769305cb2f16d21def96967a3a14728fbb6 /t
parent9a4933c3f3585f9f2bcf1f67d3162a6cfa64f264 (diff)
downloadperl-7a7e49369367a634141dd279a31cb8e210734b24.tar.gz
Better temporary file name generation. (Avoid using ++, avoid file
names clashing between different scripts, which may now be executing in parallel) p4raw-id: //depot/perl@34173
Diffstat (limited to 't')
-rw-r--r--t/test.pl25
1 files changed, 20 insertions, 5 deletions
diff --git a/t/test.pl b/t/test.pl
index 3aeb843c97..1259ed6c4c 100644
--- a/t/test.pl
+++ b/t/test.pl
@@ -619,9 +619,24 @@ sub unlink_all {
}
}
-
-my $tmpfile = "misctmp000";
-1 while -f ++$tmpfile;
+# Avoid ++, avoid ranges, avoid split //
+my @letters = qw(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z);
+sub tempfile {
+ my $count = 0;
+ do {
+ my $temp = $count;
+ my $try = "tmp$$";
+ do {
+ $try .= $letters[$temp % 26];
+ $count = int ($temp / 26);
+ } while $temp;
+ return $try unless -e $try;
+ $count = $count + 1;
+ } while $count < 26 * 26;
+ die "Can't find temporary file name starting 'tmp$$'";
+}
+
+my $tmpfile = tempfile();
END { unlink_all $tmpfile }
#
@@ -658,8 +673,8 @@ sub _fresh_perl {
# Clean up the results into something a bit more predictable.
$results =~ s/\n+$//;
- $results =~ s/at\s+misctmp\d+\s+line/at - line/g;
- $results =~ s/of\s+misctmp\d+\s+aborted/of - aborted/g;
+ $results =~ s/at\s+tmp\d+[A-Z][A-Z]?\s+line/at - line/g;
+ $results =~ s/of\s+tmp\d+[A-Z][A-Z]?\s+aborted/of - aborted/g;
# bison says 'parse error' instead of 'syntax error',
# various yaccs may or may not capitalize 'syntax'.