This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Update Digest-SHA to CPAN version 6.01
[perl5.git] / dist / PathTools / t / cwd_enoent.t
1 use warnings;
2 use strict;
3
4 use Test::More skip_all => "infinite loop seen on FreeBSD [perl #132651]";
5
6 use Config;
7 use Errno qw(ENOENT);
8 use File::Temp qw(tempdir);
9 use Test::More;
10
11 my $tmp = tempdir(CLEANUP => 1);
12 unless(mkdir("$tmp/testdir") && chdir("$tmp/testdir") && rmdir("$tmp/testdir")){
13     plan skip_all => "can't be in non-existent directory";
14 }
15
16 plan tests => 8;
17 my $EXTRA_ABSPATH_TESTS = ($Config{prefix} =~ m/\//) && $^O ne 'cygwin';
18 require Cwd;
19
20 foreach my $type (qw(regular perl)) {
21     SKIP: {
22         skip "_perl_abs_path() not expected to work", 4
23             if $type eq "perl" &&
24                 !(($Config{prefix} =~ m/\//) && $^O ne "cygwin");
25         no warnings "redefine";
26         local *Cwd::abs_path = \&Cwd::_perl_abs_path if $type eq "perl";
27         local *Cwd::getcwd = \&Cwd::_perl_getcwd if $type eq "perl";
28         my($res, $eno);
29         $! = 0;
30         $res = Cwd::getcwd();
31         $eno = 0+$!;
32         is $res, undef, "$type getcwd result on non-existent directory";
33         is $eno, ENOENT, "$type getcwd errno on non-existent directory";
34         $! = 0;
35         $res = Cwd::abs_path(".");
36         $eno = 0+$!;
37         is $res, undef, "$type abs_path result on non-existent directory";
38         is $eno, ENOENT, "$type abs_path errno on non-existent directory";
39     }
40 }
41
42 chdir $tmp or die "$tmp: $!";
43
44 1;