This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
handy.h: Add comment
[perl5.git] / dist / PathTools / t / cwd_enoent.t
CommitLineData
d2e38af7
Z
1use warnings;
2use strict;
3
4use Config;
5use Errno qw(ENOENT);
6use File::Temp qw(tempdir);
7use Test::More;
8
9my $tmp = tempdir(CLEANUP => 1);
10unless(mkdir("$tmp/testdir") && chdir("$tmp/testdir") && rmdir("$tmp/testdir")){
11 plan skip_all => "can't be in non-existent directory";
12}
13
14plan tests => 8;
15my $EXTRA_ABSPATH_TESTS = ($Config{prefix} =~ m/\//) && $^O ne 'cygwin';
16require Cwd;
17
18foreach 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
40chdir $tmp or die "$tmp: $!";
41
421;