}
use Test::More;
+use Config qw( %Config );
BEGIN {
+ # Check whether the build is configured with -Dmksymlinks
+ our $Dmksymlinks =
+ grep { /^config_arg\d+$/ && $Config{$_} eq '-Dmksymlinks' }
+ keys %Config;
+
+ # Resolve symlink to ./TEST if this build is configured with -Dmksymlinks
+ our $file = 'TEST';
+ if ( $Dmksymlinks ) {
+ $file = readlink $file;
+ die "Can't readlink(TEST): $!" if ! defined $file;
+ }
+
our $hasst;
- eval { my @n = stat "TEST" };
+ eval { my @n = stat $file };
$hasst = 1 unless $@ && $@ =~ /unimplemented/;
unless ($hasst) { plan skip_all => "no stat"; exit 0 }
use Config;
$hasst = 0 unless $Config{'i_sysstat'} eq 'define';
unless ($hasst) { plan skip_all => "no sys/stat.h"; exit 0 }
- our @stat = stat "TEST"; # This is the function stat.
- unless (@stat) { plan skip_all => "1..0 # Skip: no file TEST"; exit 0 }
+ 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;
use_ok( 'File::stat' );
-my $stat = File::stat::stat( "TEST" ); # This is the OO stat.
+my $stat = File::stat::stat( $file ); # This is the OO stat.
ok( ref($stat), 'should build a stat object' );
is( $stat->dev, $stat[0], "device number in position 0" );
my $rv = eval "-$_ \$stat";
ok( !$@, "-$_ overload succeeds" )
or diag( $@ );
- is( $rv, eval "-$_ 'TEST'", "correct -$_ overload" );
+ is( $rv, eval "-$_ \$file", "correct -$_ overload" );
}
}
SKIP: {
local *STAT;
- skip("Could not open file: $!", 2) unless open(STAT, 'TEST');
+ skip("Could not open file: $!", 2) unless open(STAT, $file);
ok( File::stat::stat('STAT'), '... should be able to find filehandle' );
package foo;