From: Jarkko Hietaniemi Date: Fri, 7 Dec 2001 21:58:15 +0000 (+0000) Subject: Further tweakage to which_perl(). X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=85363d302da4cf6b10bf67ebe8976ce196d0a5ad;p=p5sagit%2Fp5-mst-13.2.git Further tweakage to which_perl(). p4raw-id: //depot/perl@13524 --- diff --git a/t/test.pl b/t/test.pl index 041011c..223a197 100644 --- a/t/test.pl +++ b/t/test.pl @@ -271,28 +271,43 @@ sub display { # A somewhat safer version of the sometimes wrong $^X. BEGIN: { + my $exe; eval { - require File::Spec; require Config; Config->import; }; - warn "test.pl had problems loading other modules: $@" if $@; -} + if ($@) { + warn "test.pl had problems loading Config: $@"; + $exe = ''; + } else { + $exe = $Config{_exe}; + } -# We do this at compile time before the test might have chdir'd around -# and make sure its absolute in case they do later. -my $Perl = $^X; -$Perl = - File::Spec->rel2abs(File::Spec->catfile(File::Spec->curdir(), - "perl$Config{_exe}")) - if $Perl =~ /^perl\Q$Config{_exe}\E$/i; -warn "Can't generate which_perl from $^X" unless -f $Perl; + my $Perl = $^X; -# For subcommands to use. -$ENV{PERLEXE} = $Perl; + # This doesn't absolutize the path: beware of future chdirs(). + # We could do File::Spec->abs2rel() but that does getcwd()s, + # which is a bit heavyweight to do here. -sub which_perl { - return $Perl; + if ($Perl =~ /^perl\Q$exe\E$/i) { + eval { + require File::Spec; + }; + if ($@) { + warn "test.pl had problems loading File::Spec: $@"; + } else { + $Perl = File::Spec->catfile(File::Spec->curdir(), "perl$exe"); + } + } + + warn "Can't generate which_perl from $^X" unless -f $Perl; + + # For subcommands to use. + $ENV{PERLEXE} = $Perl; + + sub which_perl { + return $Perl; + } } 1;