16 print +(defined(&cwd) &&
19 defined(&fastgetcwd) ?
20 "" : "not "), "ok 1\n";
21 print +(!defined(&chdir) &&
22 !defined(&abs_path) &&
23 !defined(&fast_abs_path) ?
24 "" : "not "), "ok 2\n";
26 # XXX force Cwd to bootsrap its XSUBs since we have set @INC = "../lib"
27 # XXX and subsequent chdir()s can make them impossible to find
30 # Must find an external pwd (or equivalent) command.
33 ($^O eq "MSWin32") ? "cd" : (grep { -x && -f } map { "$_/pwd" }
34 split m/$Config{path_sep}/, $ENV{PATH})[0];
36 if ($^O eq 'VMS') { $pwd_cmd = 'SHOW DEFAULT'; }
38 if (defined $pwd_cmd) {
39 chomp(my $start = `$pwd_cmd`);
40 # Win32's cd returns native C:\ style
41 $start =~ s,\\,/,g if $^O eq 'MSWin32';
42 # DCL SHOW DEFAULT has leading spaces
43 $start =~ s/^\s+// if $^O eq 'VMS';
46 print "ok $_ # Skip: '$pwd_cmd' failed\n";
51 my $fastcwd = fastcwd;
52 my $fastgetcwd = fastgetcwd;
53 print +($cwd eq $start ? "" : "not "), "ok 3\n";
54 print +($getcwd eq $start ? "" : "not "), "ok 4\n";
55 print +($fastcwd eq $start ? "" : "not "), "ok 5\n";
56 print +($fastgetcwd eq $start ? "" : "not "), "ok 6\n";
60 print "ok $_ # Skip: no pwd command found\n";
64 mkdir "pteerslt", 0777;
65 mkdir "pteerslt/path", 0777;
66 mkdir "pteerslt/path/to", 0777;
67 mkdir "pteerslt/path/to/a", 0777;
68 mkdir "pteerslt/path/to/a/dir", 0777;
69 Cwd::chdir "pteerslt/path/to/a/dir";
72 my $fastcwd = fastcwd;
73 my $fastgetcwd = fastgetcwd;
74 my $want = "t/pteerslt/path/to/a/dir";
75 # This checked out OK on ODS-2 and ODS-5:
76 $want = "T\.PTEERSLT\.PATH\.TO\.A\.DIR\]";
77 print +($cwd =~ m|$want$| ? "" : "not "), "ok 7\n";
78 print +($getcwd =~ m|$want$| ? "" : "not "), "ok 8\n";
79 print +($fastcwd =~ m|$want$| ? "" : "not "), "ok 9\n";
80 print +($fastgetcwd =~ m|$want$| ? "" : "not "), "ok 10\n";
82 # Cwd::chdir should also update $ENV{PWD}
84 print +($ENV{PWD} =~ m|$want$| ? "" : "not "), "ok 11\n";
85 Cwd::chdir ".."; rmdir "dir";
87 Cwd::chdir ".."; rmdir "a";
89 Cwd::chdir ".."; rmdir "to";
91 Cwd::chdir ".."; rmdir "path";
93 Cwd::chdir ".."; rmdir "pteerslt";
96 # This checked out OK on ODS-2 and ODS-5:
97 print +($ENV{PWD} =~ m|\bT\]$| ? "" : "not "), "ok 12\n";
100 print +($ENV{PWD} =~ m|\bt$| ? "" : "not "), "ok 12\n";
103 if ($Config{d_symlink}) {
104 my @dirs = split " " => $Config{libpth};
105 my $target = pop @dirs;
106 symlink $target => "linktest";
109 my $rel = "../../t/linktest";
111 my $abs_path = Cwd::abs_path($rel);
112 my $fast_abs_path = Cwd::fast_abs_path($rel);
113 print +($abs_path eq $target ? "" : "not "), "ok 13\n";
114 print +($fast_abs_path eq $target ? "" : "not "), "ok 14\n";
120 print "ok 13 # skipped\n";
121 print "ok 14 # skipped\n";