develooper Front page | perl.perl5.porters | Postings from August 2008

[PATCH] Re: Change 34184: Convert all unimaginative (ie racecondition) temporary file names to

Thread Next
From:
Bram
Date:
August 12, 2008 10:05
Subject:
[PATCH] Re: Change 34184: Convert all unimaginative (ie racecondition) temporary file names to
Message ID:
20080812190500.3ns5yf7ibocgo0w0@horde.wizbit.be
Citeren Nicholas Clark <nwc10+p5p4@colon.colondot.net>:

> Change 34184 by nicholas@nicholas-pecuchet on 2008/08/08 09:59:45
>
> 	Convert all unimaginative (ie race condition) temporary file names to
> 	use test.pl's tempfile().
>
> Affected files ...
>
> ... //depot/perl/t/comp/multiline.t#13 edit
> ... //depot/perl/t/comp/script.t#14 edit
> ... //depot/perl/t/comp/use.t#32 edit
> ... //depot/perl/t/comp/utf.t#6 edit
> ... //depot/perl/t/run/cloexec.t#5 edit
> ... //depot/perl/t/run/runenv.t#13 edit
> ... //depot/perl/t/run/switchC.t#7 edit
> ... //depot/perl/t/run/switchF1.t#2 edit
> ... //depot/perl/t/run/switchd.t#7 edit
> ... //depot/perl/t/run/switches.t#27 edit
> ... //depot/perl/t/run/switcht.t#5 edit
>
> Differences ...
>
> ==== //depot/perl/t/comp/multiline.t#13 (xtext) ====
> Index: perl/t/comp/multiline.t
> --- perl/t/comp/multiline.t#12~30971~	2007-04-17 10:12:23.000000000 -0700
> +++ perl/t/comp/multiline.t	2008-08-08 02:59:45.000000000 -0700
> @@ -8,7 +8,8 @@
>
>  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 @@
>  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>) {
> @@ -42,12 +43,11 @@
>  is($., 7,       '    $.' );
>
>  $out = (($^O eq 'MSWin32') || $^O eq 'NetWare' || $^O eq 'VMS') ?   
> `type Comp.try`
> -    : ($^O eq 'MacOS') ? `catenate Comp.try`
> -    : `cat Comp.try`;
> +    : ($^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);
>

Missed one Comp.try in the MSWin32 case. (type Comp.try)

Patch attached.



Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About