Skip to content

Commit

Permalink
op/stat.t: Skip test if environment not suitable.
Browse files Browse the repository at this point in the history
Subtly, if this test is run in a directory containing a file named '2',
it will fail.  It's simplest to just skip the test for this rare event.
  • Loading branch information
khwilliamson committed Jun 17, 2016
1 parent b20d3b8 commit 6405d2e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions t/op/stat.t
Expand Up @@ -637,14 +637,16 @@ is join("-", 1,2,3,(stat stat stat),4,5,6), "1-2-3-4-5-6",
'stat inside stat gets scalar context';

# [perl #126162] stat an array should not work
my $Errno_loaded = eval { require Errno };
my $statfile = './op/stat.t';
my @statarg = ($statfile, $statfile);
ok !stat(@statarg),
'stat on an array of valid paths should warn and should not return any data';
my $error = 0+$!;
# skip if -e '2'.
SKIP:
{
skip "There is a file named '2', which invalidates this test", 2 if -e '2';

my $Errno_loaded = eval { require Errno };
my @statarg = ($statfile, $statfile);
ok !stat(@statarg),
'stat on an array of valid paths should warn and should not return any data';
my $error = 0+$!;
skip "Errno not available", 1
unless $Errno_loaded;
is $error, &Errno::ENOENT,
Expand Down

0 comments on commit 6405d2e

Please sign in to comment.