develooper Front page | perl.perl5.porters | Postings from January 2012

Re: [perl.git] branch blead, updated. v5.15.6-545-g0d5064f

Thread Next
From:
Craig A. Berry
Date:
January 15, 2012 04:53
Subject:
Re: [perl.git] branch blead, updated. v5.15.6-545-g0d5064f
Message ID:
craigberry-4AF0B1.06533315012012@cpc2-bmly6-0-0-cust974.2-3.cable.virginmedia.com
In article <E1RmBto-0000gR-FW@camel.ams6.corp.booking.com>,
 sprout@cpan.org ("Father Chrysostomos") wrote:


> 
> commit ac737fdfcf5daa2a78d524ec276c62b4586f2e6d
> Author: Father Chrysostomos <sprout@cpan.org>
> Date:   Sat Jan 14 12:59:34 2012 -0800
> 
>     stat.t: Make test for -T _ and lstat more robust
>     
>     It is now less likely to fail if one runs stat.t manually when tests
>     are running, due to the random file name.  It also works now when the
>     script chdirs (when run outside t), because it no longer relies on $0
>     being a real file.
>     
>     That last part was broken by commit ad2d99e39, which made -T _ more
>     consistent when it cannot open the file.  It used to set the stat
>     type, but not the success status (as of commit 25988e07, which
>     fixed #4253).
> 
> M	t/op/stat.t
> -----------------------------------------------------------------------
> 


> diff --git a/t/op/stat.t b/t/op/stat.t
> index dfc00b9..59c7398 100644
> --- a/t/op/stat.t
> +++ b/t/op/stat.t
> @@ -20,7 +20,7 @@ if(eval {require File::Spec; 1}) {
>  }
>  
>  
> -plan tests => 111;
> +plan tests => 112;
>  
>  my $Perl = which_perl();
>  
> @@ -465,14 +465,21 @@ lstat "test.pl";
>  }
>  like $@, qr/^The stat preceding lstat\(\) wasn't an lstat at /,
>  'stat $ioref resets stat type';
> +
> +{
> +    my @statbuf = stat STDOUT;
> +    stat "test.pl";
> +    my @lstatbuf = lstat *STDOUT{IO};
> +    is "@lstatbuf", "@statbuf", 'lstat $ioref reverts to regular fstat';
> +}
>    
>  SKIP: {
>      skip "No lstat", 2 unless $Config{d_lstat};
>  
>      # bug id 20020124.004
>      # If we have d_lstat, we should have symlink()
> -    my $linkname = 'dolzero';
> -    symlink $0, $linkname or die "# Can't symlink $0: $!";
> +    my $linkname = 'stat-' . rand =~ y/.//cdr;

If the intention is to make the link name contain a random number, it 
might be better to remove the dot from the return value of rand() rather 
than removing everything except the dot :-).  In other words, unless I'm 
really missing something, you don't want the /c in the replacement 
operation.

% perl -e '$x = qq/stat-/ . rand() =~ y/.//cdr; print qq/$x\n/;'
stat-.
% perl -e '$x = qq/stat-/ . rand() =~ y/.//dr; print qq/$x\n/;'
stat-0835875728008435

The new -T tests all fail on VMS, which is something I hope to dig into 
shortly, but this was something that I stumbled over first.

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