Commit | Line | Data |
---|---|---|
d2e38af7 Z |
1 | use warnings; |
2 | use strict; | |
3 | ||
4 | use Config; | |
5 | use Errno qw(ENOENT); | |
6 | use File::Temp qw(tempdir); | |
7 | use Test::More; | |
8 | ||
9 | my $tmp = tempdir(CLEANUP => 1); | |
10 | unless(mkdir("$tmp/testdir") && chdir("$tmp/testdir") && rmdir("$tmp/testdir")){ | |
11 | plan skip_all => "can't be in non-existent directory"; | |
12 | } | |
13 | ||
14 | plan tests => 8; | |
15 | my $EXTRA_ABSPATH_TESTS = ($Config{prefix} =~ m/\//) && $^O ne 'cygwin'; | |
16 | require Cwd; | |
17 | ||
18 | foreach my $type (qw(regular perl)) { | |
19 | SKIP: { | |
20 | skip "_perl_abs_path() not expected to work", 4 | |
21 | if $type eq "perl" && | |
22 | !(($Config{prefix} =~ m/\//) && $^O ne "cygwin"); | |
23 | no warnings "redefine"; | |
24 | local *Cwd::abs_path = \&Cwd::_perl_abs_path if $type eq "perl"; | |
25 | local *Cwd::getcwd = \&Cwd::_perl_getcwd if $type eq "perl"; | |
26 | my($res, $eno); | |
27 | $! = 0; | |
28 | $res = Cwd::getcwd(); | |
29 | $eno = 0+$!; | |
30 | is $res, undef, "$type getcwd result on non-existent directory"; | |
31 | is $eno, ENOENT, "$type getcwd errno on non-existent directory"; | |
32 | $! = 0; | |
33 | $res = Cwd::abs_path("."); | |
34 | $eno = 0+$!; | |
35 | is $res, undef, "$type abs_path result on non-existent directory"; | |
36 | is $eno, ENOENT, "$type abs_path errno on non-existent directory"; | |
37 | } | |
38 | } | |
39 | ||
40 | chdir $tmp or die "$tmp: $!"; | |
41 | ||
42 | 1; |