summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Rinaldo <toddr@cpan.org>2010-11-11 17:08:34 -0600
committerFather Chrysostomos <sprout@cpan.org>2010-11-11 18:08:46 -0800
commit3c1f5943e7d7227d005f4786558b7871b89e7a50 (patch)
tree8f84e6cc228a81c2cd5f2fd1cb9c63f9e0e80896 /lib
parent46787c0e32a676e3fcb60d752d4858316dc1ef77 (diff)
downloadperl-3c1f5943e7d7227d005f4786558b7871b89e7a50.tar.gz
RT 79076: fix File::stat overload tests -x and -X when uid is root
Diffstat (limited to 'lib')
-rw-r--r--lib/File/stat.pm4
-rw-r--r--lib/File/stat.t19
2 files changed, 20 insertions, 3 deletions
diff --git a/lib/File/stat.pm b/lib/File/stat.pm
index a783e08cac..d4030334d8 100644
--- a/lib/File/stat.pm
+++ b/lib/File/stat.pm
@@ -84,7 +84,9 @@ else {
my ($s, $mode, $eff) = @_;
my $uid = $eff ? $> : $<;
- $^O ne "VMS" and $uid == 0 and return 1;
+ # If we're root on unix and we are not testing for exectable
+ # status, then all file tests are true.
+ $^O ne "VMS" and $uid == 0 and !($mode & 0111) and return 1;
my ($stmode, $stuid, $stgid) = @$s[2,4,5];
diff --git a/lib/File/stat.t b/lib/File/stat.t
index afeb446b13..40bd86bd19 100644
--- a/lib/File/stat.t
+++ b/lib/File/stat.t
@@ -21,7 +21,7 @@ BEGIN {
our $file = '../lib/File/stat.t';
if ( $Dmksymlinks ) {
$file = readlink $file;
- die "Can't readlink(TEST): $!" if ! defined $file;
+ die "Can't readlink(../lib/File/stat.t): $!" if ! defined $file;
}
our $hasst;
@@ -42,7 +42,7 @@ BEGIN {
our @stat = stat $file; # This is the function stat.
unless (@stat) { plan skip_all => "1..0 # Skip: no file $file"; exit 0 }
-plan tests => 19 + 24*2 + 3;
+plan tests => 19 + 24*2 + 4 + 3;
use_ok( 'File::stat' );
@@ -91,6 +91,21 @@ for (split //, "rwxoRWXOezsfdlpSbcugkMCA") {
}
}
+SKIP: {
+ my $file = '../perl';
+ -e $file && -x $file or skip "$file is not present and exectable", 4;
+ $^O eq "VMS" and skip "File::stat ignores VMS ACLs", 4;
+
+ my $stat = File::stat::stat( $file ); # This is the OO stat.
+ foreach (qw/x X/) {
+ my $rv = eval "-$_ \$stat";
+ ok( !$@, "-$_ overload succeeds" )
+ or diag( $@ );
+ is( $rv, eval "-$_ \$file", "correct -$_ overload" );
+ }
+}
+
+
for (split //, "tTB") {
eval "-$_ \$stat";
like( $@, qr/\Q-$_ is not implemented/, "-$_ overload fails" );