Steffen Mueller wrote:
Malcolm Nooning schrieb:
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]);
}

Right. It usually works, too. Except when the tests are somehow killed by the user and normal clean-up doesn't happen. Switching to using File::Temp's cleanup routines won't fix this, of course. Two ways out:

- Use File::Temp to create a temporary directory with an unknown part, i.e. using a template "pp_switch_tests_XXXXX" with XXXXX replaced by a random string for each run. - Use the "pp_switch_tests" subdirectory of the extracted distribution's base directory. If the user does an rm -rf PAR-Packer-0.9XX, that'll be cleaned up for him. If he can't because parts are owned by root, he'll figure that out alright. He won't necessarily figure out why, after he extracted a fresh copy, the tests fail with a permission error. (Because the pp_switch_tests dir in /tmp is owned by root.)

Steffen
-------------------------
Oh, my. In just two short years I forget completely what I did. I feel like Dori's brother (she is the one who helped find Nemo, if you know who he is).

See the "startdir=s" below? It means whatever invokes automated_pp_test.pl can name it's own head starting test directory. All options are, um, optional.

my $startdir = "";
GetOptions(  "verbose"         => \$verbose,
             "debug"           => \$debug,
             "startdir=s"      => \$startdir,
             "perl_location=s" => \$perl,
             "par_location=s"  => \$par,
          );

Later on I destroy it with
$startdir ||= File::Spec->catdir(File::Spec->tmpdir, 'pp_switch_tests');

I should have done this:
if ($startdir !~ m/\w+/) {
  $startdir ||= File::Spec->catdir(File::Spec->tmpdir, 'pp_switch_tests');
}

But, since we do not want it under /tmp anymore, I will do this


if ($startdir eq "") {
  $startdir = $orig_dir; # Aready known.
                         #It is wherever the automated_pp_test.pl is.
}

I do not think anyone would ever want to name their own test directory. In truth, I never have myself. However, if they do, the capability is there If they use illegal characters or something, well, if they know enough to name their own directory, they would figure out pretty quickly what was wrong.


If this can be agreed upon, I will test it out.


Reply via email to