Subject: | Tests file if the file /tmp/t exists |
Problem observed with debian 'etch' on linux 3.2, running perl 5.10.0 (which are not believed to be relevant to the reported failure).
Steps to reproduce:
1. Create a file called /tmp/t.
2. Try to install File::SearchPath:
cpan
install File::SearchPath
3. Tests fail with the output:
----
t/search.t .. 1/14
# Failed test 'Do not find dir when not looking for dir'
# at t/search.t line 62.
# Looks like you failed 1 test of 14.
t/search.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/14 subtests
Test Summary Report
-------------------
t/search.t (Wstat: 256 Tests: 14 Failed: 1)
Failed test: 13
Non-zero exit status: 1
Files=1, Tests=14, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.03 cusr 0.00 csys = 0.05 CPU)
Result: FAIL
Failed 1/1 test programs. 1/14 subtests failed.
----
Expected behaviour:
Should not fail based on arbitrary (uncontrolled) files outside the environment being tested by the tool.
Root cause:
This is caused by the test code:
----
$fullpath = File::SearchPath::searchpath( "t", env => "MYPATH" );
ok(!$fullpath, "Do not find dir when not looking for dir");
----
because MYPATH has been set up previously as:
----
setpath( "MYPATH", File::Spec->curdir, File::Spec->tmpdir );
----
which includes the temporary directory in the search.
Workaround:
The workaround for this is to delete the file /tmp/t, however if such a file is not owned by the user performing the installation, this may not be possible. In which case it may be necessary to remove File::Spec->tmpdir from the setpath statement (which may have other unintended side effects).