From: Jarkko Hietaniemi Date: Thu, 29 Mar 2001 14:51:47 +0000 (+0000) Subject: Reintroduce the use of external pwd. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=da3f15f45759606922ae459be6ba8bc2810578ad;p=p5sagit%2Fp5-mst-13.2.git Reintroduce the use of external pwd. p4raw-id: //depot/perl@9441 --- diff --git a/t/lib/cwd.t b/t/lib/cwd.t index f9cdffb..d2c3944 100644 --- a/t/lib/cwd.t +++ b/t/lib/cwd.t @@ -10,7 +10,7 @@ use Cwd; use strict; use warnings; -print "1..10\n"; +print "1..14\n"; # check imports print +(defined(&cwd) && @@ -23,6 +23,34 @@ print +(!defined(&chdir) && !defined(&fast_abs_path) ? "" : "not "), "ok 2\n"; +# Must find an external pwd (or equivalent) command. + +my $pwd_cmd = + ($^O eq "Win32") ? "cd" : (grep { -x && -f } map { "$_/pwd" } + split m/$Config{path_sep}/, $ENV{PATH})[0]; + +if (defined $pwd_cmd) { + chomp(my $start = `$pwd_cmd`); + if ($?) { + for (3..6) { + print "ok $_ # Skip: '$pwd_cmd' failed\n"; + } + } else { + my $cwd = cwd; + my $getcwd = getcwd; + my $fastcwd = fastcwd; + my $fastgetcwd = fastgetcwd; + print +($cwd eq $start ? "" : "not "), "ok 3\n"; + print +($getcwd eq $start ? "" : "not "), "ok 4\n"; + print +($fastcwd eq $start ? "" : "not "), "ok 5\n"; + print +($fastgetcwd eq $start ? "" : "not "), "ok 6\n"; + } +} else { + for (3..6) { + print "ok $_ # Skip: no pwd command found\n"; + } +} + mkdir "pteerslt", 0777; mkdir "pteerslt/path", 0777; mkdir "pteerslt/path/to", 0777; @@ -34,19 +62,19 @@ my $getcwd = getcwd; my $fastcwd = fastcwd; my $fastgetcwd = fastgetcwd; my $want = "t/pteerslt/path/to/a/dir"; -print +($cwd =~ m|$want$| ? "" : "not "), "ok 3\n"; -print +($getcwd =~ m|$want$| ? "" : "not "), "ok 4\n"; -print +($fastcwd =~ m|$want$| ? "" : "not "), "ok 5\n"; -print +($fastgetcwd =~ m|$want$| ? "" : "not "), "ok 6\n"; +print +($cwd =~ m|$want$| ? "" : "not "), "ok 7\n"; +print +($getcwd =~ m|$want$| ? "" : "not "), "ok 8\n"; +print +($fastcwd =~ m|$want$| ? "" : "not "), "ok 9\n"; +print +($fastgetcwd =~ m|$want$| ? "" : "not "), "ok 10\n"; # Cwd::chdir should also update $ENV{PWD} -print +($ENV{PWD} =~ m|$want$| ? "" : "not "), "ok 7\n"; +print +($ENV{PWD} =~ m|$want$| ? "" : "not "), "ok 11\n"; Cwd::chdir ".."; rmdir "dir"; Cwd::chdir ".."; rmdir "a"; Cwd::chdir ".."; rmdir "to"; Cwd::chdir ".."; rmdir "path"; Cwd::chdir ".."; rmdir "pteerslt"; -print +($ENV{PWD} =~ m|\bt$| ? "" : "not "), "ok 8\n"; +print +($ENV{PWD} =~ m|\bt$| ? "" : "not "), "ok 12\n"; if ($Config{d_symlink}) { my @dirs = split " " => $Config{libpth}; @@ -58,13 +86,13 @@ if ($Config{d_symlink}) { my $abs_path = Cwd::abs_path($rel); my $fast_abs_path = Cwd::fast_abs_path($rel); - print +($abs_path eq $target ? "" : "not "), "ok 9\n"; - print +($fast_abs_path eq $target ? "" : "not "), "ok 10\n"; + print +($abs_path eq $target ? "" : "not "), "ok 13\n"; + print +($fast_abs_path eq $target ? "" : "not "), "ok 14\n"; chdir ".."; rmdir "pteerslt"; unlink "linktest"; } else { - print "ok 9 # Skip: no symlink\n"; - print "ok 10 # Skip: no symlink\n"; + print "ok 13 # skipped\n"; + print "ok 14 # skipped\n"; }