diff options
author | Bram <perl-rt@wizbit.be> | 2008-08-10 22:36:27 +0200 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2008-09-05 13:59:17 +0000 |
commit | 7482400511cbbd05a08b338bfd2b46c1abc2d919 (patch) | |
tree | fde8973ff833e2131cb165d844da963b3bae63d1 /t/comp | |
parent | 3a3807990ef09855532ad41a51033a0025af3399 (diff) | |
download | perl-7482400511cbbd05a08b338bfd2b46c1abc2d919.tar.gz |
Integrate:
[ 34180]
Use test.pl's tempfile().
[ 34182]
Convert all unimaginative (ie race condition) temporary file names to
use test.pl's tempfile().
[ 34184]
Convert all unimaginative (ie race condition) temporary file names to
use test.pl's tempfile().
[ 34196]
Subject: Avoid a potential testing race condition in lib/Dirhandle.ttest.
Message-ID: <20080810203627.vj786wb688skc44w@horde.wizbit.be>
Date: Sun, 10 Aug 2008 20:36:27 +0200
[ 34203]
VMS-specific follow-up to tempfile name changes in 34182, plus
a TODO in dup.t that's long since to-done.
[ 34205]
Subject: [PATCH] Re: Change 34184: Convert all unimaginative (ie race condition) temporary file names to
From: Bram <p5p@perl.wizbit.be>
Date: Tue, 12 Aug 2008 19:05:00 +0200
Message-ID: <20080812190500.3ns5yf7ibocgo0w0@horde.wizbit.be>
(Change 34184 missed one Comp.try in the MSWin32 case, which caused this
test to fail on Win32)
p4raw-link: @34205 on //depot/perl: 06d90eb2f694021a5def99acedeffe3d57873a83
p4raw-link: @34203 on //depot/perl: 7aa55bb4d7409fae441c5fde09543172f4df350d
p4raw-link: @34196 on //depot/perl: ffe4764e6903def60304ff584612fb863707cd05
p4raw-link: @34184 on //depot/perl: 2d90ac9586ffb5c785730411e7c6e986a8a1190c
p4raw-link: @34182 on //depot/perl: 62a28c976c312a2c7269acc71060b1037a453bea
p4raw-link: @34180 on //depot/perl: 1c25d394345c1b97c9cfd949fe3d2e3296fd9681
p4raw-id: //depot/maint-5.10/perl@34273
p4raw-integrated: from //depot/perl@34271 'copy in' t/comp/script.t
(@14340..) t/run/switcht.t (@18453..) t/io/fflush.t (@19491..)
lib/DirHandle.t (@19580..) t/run/switchF1.t (@23730..)
t/op/lfs.t (@25071..) t/op/mydef.t (@25180..) t/io/crlf.t
(@25625..) t/io/nargv.t (@25973..) t/io/read.t t/io/tell.t
t/op/read.t (@26178..) t/io/through.t (@26857..) t/comp/utf.t
t/io/utf8.t t/run/switchC.t (@29056..) t/run/switchd.t
(@30059..) t/io/inplace.t t/io/iprefix.t (@30543..)
t/op/readline.t (@30750..) t/run/cloexec.t (@31438..)
t/op/goto.t (@31504..) t/io/layers.t (@31648..) t/comp/use.t
(@32003..) t/op/taint.t (@32278..) t/op/closure.t (@32906..)
t/op/fork.t (@33749..) t/op/dbm.t (@33768..) t/op/stat.t
(@34056..) t/op/eval.t (@34069..) t/op/inccode.t (@34092..)
t/op/runlevel.t (@34180..) t/io/dup.t t/io/fs.t (@34182..)
t/run/runenv.t (@34183..) t/comp/multiline.t (@34184..) 'merge
in' t/io/open.t (@34042..)
p4raw-integrated: from //depot/perl@34184 'merge in' t/run/switches.t
(@34040..)
Diffstat (limited to 't/comp')
-rwxr-xr-x | t/comp/multiline.t | 14 | ||||
-rwxr-xr-x | t/comp/script.t | 10 | ||||
-rwxr-xr-x | t/comp/use.t | 8 | ||||
-rw-r--r-- | t/comp/utf.t | 6 |
4 files changed, 19 insertions, 19 deletions
diff --git a/t/comp/multiline.t b/t/comp/multiline.t index e8b7cf4a16..1af76fce87 100755 --- a/t/comp/multiline.t +++ b/t/comp/multiline.t @@ -8,7 +8,8 @@ BEGIN { plan(tests => 6); -open(TRY,'>Comp.try') || (die "Can't open temp file."); +my $filename = tempfile(); +open(TRY,'>',$filename) || (die "Can't open $filename: $!"); $x = 'now is the time for all good men @@ -28,7 +29,7 @@ is($x, $y, 'test data is sane'); print TRY $x; close TRY or die "Could not close: $!"; -open(TRY,'Comp.try') || (die "Can't reopen temp file."); +open(TRY,$filename) || (die "Can't reopen $filename: $!"); $count = 0; $z = ''; while (<TRY>) { @@ -41,13 +42,12 @@ is($z, $y, 'basic multiline reading'); is($count, 7, ' line count'); is($., 7, ' $.' ); -$out = (($^O eq 'MSWin32') || $^O eq 'NetWare' || $^O eq 'VMS') ? `type Comp.try` - : ($^O eq 'MacOS') ? `catenate Comp.try` - : `cat Comp.try`; +$out = (($^O eq 'MSWin32') || $^O eq 'NetWare' || $^O eq 'VMS') ? `type $filename` + : ($^O eq 'MacOS') ? `catenate $filename` + : `cat $filename`; like($out, qr/.*\n.*\n.*\n$/); -close(TRY) || (die "Can't close temp file."); -unlink 'Comp.try' || `/bin/rm -f Comp.try`; +close(TRY) || (die "Can't close $filename: $!"); is($out, $y); diff --git a/t/comp/script.t b/t/comp/script.t index 6efffdf81a..83d733abd2 100755 --- a/t/comp/script.t +++ b/t/comp/script.t @@ -8,22 +8,22 @@ BEGIN { my $Perl = which_perl(); +my $filename = tempfile(); + print "1..3\n"; $x = `$Perl -le "print 'ok';"`; if ($x eq "ok\n") {print "ok 1\n";} else {print "not ok 1\n";} -open(try,">Comp.script") || (die "Can't open temp file."); +open(try,">$filename") || (die "Can't open temp file."); print try 'print "ok\n";'; print try "\n"; close try or die "Could not close: $!"; -$x = `$Perl Comp.script`; +$x = `$Perl $filename`; if ($x eq "ok\n") {print "ok 2\n";} else {print "not ok 2\n";} -$x = `$Perl <Comp.script`; +$x = `$Perl <$filename`; if ($x eq "ok\n") {print "ok 3\n";} else {print "not ok 3\n";} - -unlink 'Comp.script' || `/bin/rm -f Comp.script`; diff --git a/t/comp/use.t b/t/comp/use.t index a43bbeb44c..d3a3568c1c 100755 --- a/t/comp/use.t +++ b/t/comp/use.t @@ -190,12 +190,12 @@ if ($^O eq 'MacOS') { { # Regression test for patch 14937: # Check that a .pm file with no package or VERSION doesn't core. - open F, ">xxx.pm" or die "Cannot open xxx.pm: $!\n"; + open F, ">xxx$$.pm" or die "Cannot open xxx$$.pm: $!\n"; print F "1;\n"; close F; - eval "use lib '.'; use xxx 3;"; - like ($@, qr/^xxx defines neither package nor VERSION--version check failed at/); - unlink 'xxx.pm'; + eval "use lib '.'; use xxx$$ 3;"; + like ($@, qr/^xxx$$ defines neither package nor VERSION--version check failed at/); + unlink "xxx$$.pm"; } my @ver = split /\./, sprintf "%vd", $^V; diff --git a/t/comp/utf.t b/t/comp/utf.t index f0673eb964..6421f9330d 100644 --- a/t/comp/utf.t +++ b/t/comp/utf.t @@ -26,12 +26,12 @@ my $BOM = chr(0xFEFF); sub test { my ($enc, $tag, $bom) = @_; - open(UTF_PL, ">:raw:encoding($enc)", "utf.pl") + open(UTF_PL, ">:raw:encoding($enc)", "utf$$.pl") or die "utf.pl($enc,$tag,$bom): $!"; print UTF_PL $BOM if $bom; print UTF_PL "$tag\n"; close(UTF_PL); - my $got = do "./utf.pl"; + my $got = do "./utf$$.pl"; is($got, $tag); } @@ -53,5 +53,5 @@ test("utf16be", 1234, 0); test("utf16be", 12345, 0); END { - 1 while unlink "utf.pl"; + 1 while unlink "utf$$.pl"; } |