I should add that the lines below are already in the code so normally
there would be a cleanup.
# Clean up after us.
END {
chdir(File::Spec->tmpdir);
File::Path::rmtree([$startdir]);
}
-------- Original Message --------
Subject: Re: pp tests should use File::Temp?
Date: Tue, 23 Jan 2007 08:24:41 -0500
From: m.nooning <[EMAIL PROTECTED]>
CC: [email protected]
References: <[EMAIL PROTECTED]>
<[EMAIL PROTECTED]>
Steffen Mueller wrote:
Hi Eric,
Eric Wilhelm schrieb:
I was running the tests as my normal user, and it appears that I
killed it as root, or else it didn't properly cleanup at some point.
Seems like it should probably use File::Temp::tempdir(), or at least
create the temp dir inside of the distribution tree.
Can't remove directory /tmp/pp_switch_tests/temp0 (Permission denied)
at a
utomated_pp_test.pl line 6966
Can't remove directory /tmp/pp_switch_tests (Directory not empty) at
autom
ated_pp_test.pl line 6966
I'm confident this would be a good idea. We had several inquiries about
this (dead pp_switch_tests lying around, owned by root) in the past. If
the folder was in the distribution directory, people might figure out
that it's related to them running stuff as root more easily. And the
mess will be cleaned up when the re-extract the module .tar.gz.
Malcolm wrote the automated_pp_test.pl. I haven't really read all of it.
(It's a lot of code!) I don't know how much work it'll be. Perhaps a
five line change perhaps several dozens across 7000 lines...
Takers welcome!
Steffen
There might be a caveat here.
The change would be made in one place. That is not the problem.
The head of the test directory is $startdir, where, in the code,
$startdir ||= File::Spec->catdir(File::Spec->tmpdir, 'pp_switch_tests');
and File::Spec->tmpdir (from search.cpan.org)
Returns a string representation of the first writable directory from a
list of possible temporary directories. Returns the current directory if
no writable temporary directories are found. The list of directories
checked depends on the platform; e.g. File::Spec::Unix checks
$ENV{TMPDIR} (unless taint is on) and /tmp.
Thus, as it stands now, there will always be a defined $startdir even if
all else fails.
To make the needed change, I would simply "use "Cwd", and
my $startdir = cwd();
I need to ask, suppose this is a CPAN install? That is,
cpan>install PAR::Packer
In that case, where would the cwd be? I am guessing /home/logname/ so
would that really be what we would want?
Any other ideas?