CC: | dagolden [...] cpan.org |
Subject: | File::pushd failure on Mac OS X due to _perl_abs_path returning empty string |
Date: | Thu, 9 Jul 2009 15:01:49 -0700 |
To: | bug-File-pushd [...] rt.cpan.org |
From: | Randall Lucas <rlucas [...] rlucas.net> |
Message body is not shown because sender requested not to inline it.
File::pushd fails to build on my Mac OS X system due to test failures
(below). They start with the 'pushd to nonexistant directory croaks'
failure, and cascade from there.
My version of Cwd and Mac OS X cause the "_perl_abs_path()" version of
"abs_path()" to get called from File::pushd::pushd().
_perl_abs_path(), when given a nonexistent directory, does NOT die() but
rather returns an empty string.
Therefore, the eval{}; in pushd() that tries to set $dest based on abs_path
ends up setting $dest=''.
The results are bad in two ways. First, pushd() never fails, since it
doesn't get $@ from the eval, nor does it get a failure from chdir $dest.
That causes the first test failure.
Second, since "chdir $dest" gets called with $dest empty, it defaults to
$ENV{HOME} as a side-effect, which screws up a bunch of the following tests.
(The behavior of Cwd is definitely suspect here. I think because the Mac OS
X implementation doesn't have an XS version, and so falls back to the
pure-Perl abs_path, I end up getting the empty-string-on-failure instead of
the croak on failure. I've also opened a ticket on Cwd / PathTools for this
issue.)
A patch is attached that causes File::pushd to pass all tests and build OK
on my system. Below are my version numbers and the "make test" output.
---
Cwd 3.2701
Mac OS X 10.5.7 (9J61)
perl, v5.8.8 built for darwin-thread-multi-2level
---
Running
[/System/Library/Perl/Extras/5.8.8/darwin-thread-multi-2level/auto/Wx/wxPerl.app/Contents/MacOS/wxPerl
/usr/bin/cpanp-run-perl
/Users/rlucas/.cpanplus/5.8.8/build/File-pushd-1.00/Makefile.PL ]...
Writing Makefile for File::pushd
Running [/usr/bin/make test]...
PERL_DL_NONLAZY=1
/System/Library/Perl/Extras/5.8.8/darwin-thread-multi-2level/auto/Wx/wxPerl.app/Contents/MacOS/wxPerl
"-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')"
t/*.t
stat(DFASDFASDFASDFAS): No such file or directory at
/Users/rlucas/.cpanplus/5.8.8/build/File-pushd-1.00/blib/lib/File/pushd.pmline
31
Use of chdir('') or chdir(undef) as chdir() is deprecated at
/Users/rlucas/.cpanplus/5.8.8/build/File-pushd-1.00/blib/lib/File/pushd.pmline
36.
# Failed test 'pushd to nonexistant directory croaks'
# at t/File_pushd.t line 38.
# ''
# doesn't match '/\ACan't/'
stat(t): No such file or directory at
/Users/rlucas/.cpanplus/5.8.8/build/File-pushd-1.00/blib/lib/File/pushd.pmline
31
Use of chdir('') or chdir(undef) as chdir() is deprecated at
/Users/rlucas/.cpanplus/5.8.8/build/File-pushd-1.00/blib/lib/File/pushd.pmline
36.
# Failed test 'change directory on pushd (relative path)'
# at t/File_pushd.t line 49.
# got: '/Users/rlucas/.cpanplus/5.8.8/build/File-pushd-1.00'
# expected: '/Users/rlucas/.cpanplus/5.8.8/build/File-pushd-1.00/t'
# Failed test 'object stringifies'
# at t/File_pushd.t line 55.
# got: ''
# expected: '/Users/rlucas/.cpanplus/5.8.8/build/File-pushd-1.00/t'
# Failed test 'revert directory when variable goes out of scope'
# at t/File_pushd.t line 63.
# got: '/Users/rlucas'
# expected: '/Users/rlucas/.cpanplus/5.8.8/build/File-pushd-1.00'
# Failed test 'revert directory when variable goes out of scope'
# at t/File_pushd.t line 78.
# got: '/Users/rlucas'
# expected: '/Users/rlucas/.cpanplus/5.8.8/build/File-pushd-1.00'
# Failed test 'revert directory when variable goes out of scope'
# at t/File_pushd.t line 91.
# got: '/Users/rlucas'
# expected: '/Users/rlucas/.cpanplus/5.8.8/build/File-pushd-1.00'
# Failed test 'revert directory when variable goes out of scope'
# at t/File_pushd.t line 105.
# got: '/Users/rlucas'
# expected: '/Users/rlucas/.cpanplus/5.8.8/build/File-pushd-1.00'
# Failed test 'pushd with no argument doesn't change directory'
# at t/File_pushd.t line 115.
# got: '/Users/rlucas'
# expected: '/Users/rlucas/.cpanplus/5.8.8/build/File-pushd-1.00'
# Failed test 'changing manually to another directory'
# at t/File_pushd.t line 119.
# got: '/Users/rlucas'
# expected: '/Users/rlucas/.cpanplus/5.8.8/build/File-pushd-1.00/t'
# Failed test 'revert directory when variable goes out of scope'
# at t/File_pushd.t line 123.
# got: '/Users/rlucas'
# expected: '/Users/rlucas/.cpanplus/5.8.8/build/File-pushd-1.00'
# Failed test 'revert directory when variable goes out of scope'
# at t/File_pushd.t line 138.
# got: '/Users/rlucas'
# expected: '/Users/rlucas/.cpanplus/5.8.8/build/File-pushd-1.00'
# Failed test 'revert directory when variable goes out of scope'
# at t/File_pushd.t line 157.
# got: '/Users/rlucas'
# expected: '/Users/rlucas/.cpanplus/5.8.8/build/File-pushd-1.00'
# Failed test 'revert directory when variable goes out of scope'
# at t/File_pushd.t line 205.
# got: '/Users/rlucas'
# expected: '/Users/rlucas/.cpanplus/5.8.8/build/File-pushd-1.00'
# Failed test 'revert directory when variable goes out of scope'
# at t/File_pushd.t line 224.
# got: '/Users/rlucas'
# expected: '/Users/rlucas/.cpanplus/5.8.8/build/File-pushd-1.00'
# Looks like you failed 14 tests of 37.
t/File_pushd.t ..
Dubious, test returned 14 (wstat 3584, 0xe00)
Failed 14/37 subtests
Test Summary Report
-------------------
t/File_pushd.t (Wstat: 3584 Tests: 37 Failed: 14)
Failed tests: 3, 5-7, 9, 11, 13-16, 18, 22, 31, 36
Non-zero exit status: 14
Files=1, Tests=37, 0 wallclock secs ( 0.03 usr 0.01 sys + 0.11 cusr 0.06
csys = 0.21 CPU)
Result: FAIL
Failed 1/1 test programs. 14/37 subtests failed.
make: *** [test_dynamic] Error 14