Re: name of perl in MakeMaker
On Mon, 01 Apr 2002 02:52:20 GMT, [EMAIL PROTECTED] (Stephen Zander) wrote in news:87hemwyvtn.fsf;pobox.com: [...] looking to invoke perl as part of his test scripts and given that the test suite will usually be invoked using FULLPERL, it makes sense to me to use that for any additional perl invocations inside that test suite. Adding the following to Makefile.PL ensures that the tests dance with the perl that brought them. [snip] If the modules has a t/*.t testbed, then the following is required instead: [see original; this may have been mangled / miswrapped by my emailer] sub MY::test_via_harness { my($self, $perl, $tests) = @_; my $_perl = $perl; $_perl = $Is_Win32 ? PERL_DL_NONLAZY=1 $perl : $_perl .= -Mblib; \t$_perl.q! -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e '$$ENV{MYPERL}=$perl; use Test::Harness qw(runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;' !.$tests\n; } with the various tests invoking $ENV{MYPERL} instead of $^X. The above is not guarenteed to work on VMS. It needs some well-placed double quotes. Would this do the trick?: =item test_via_harness Again, this is *not* MM_Unix.pm sub/method, but based on one contributed by Stephen Zander (see test_via_script) on the [EMAIL PROTECTED] List. He notes: If the modules has a t/*.t testbed, then this following is required instead [...] with the various tests invoking $ENV{MYPERL} instead of $^X. =cut sub MY::test_via_harness { my($self, $perl, $tests) = @_; my $_perl = $perl; $_perl = $Is_Win32 ? PERL_DL_NONLAZY=1 $perl : $_perl .= -Mblib; qq{\t$_perl} .q{ -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) } .qq%-e $$ENV{MYPERL}=qq[$perl];% .qq%-e use Test::Harness qw(runtests $$verbose); $$verbose=$(TEST_VERBOSE);% .qq%-e runtests @ARGV; % .qq{ $tests\n}; } Thanks very much. I have used your improvements in the [Module::]ExoBuild project I am currently doing. I haven't got a VMS system to test this on and it's not tested at all yet. OMMV. Just thought it was approximately what you meant it needed in terms of quoting fixes, also I think it is now a bit more readable. Soren A -- --*perlspinr*-- **Helping to consume excess Internet bandwidth since 1996**
Re: name of perl in MakeMaker
Regarding: Subject: Re: name of perl in MakeMaker Date: 7 Nov 2002 19:35:21 - From: [EMAIL PROTECTED] (Soren A) Newsgroups: perl.module-authors Boy did I screw up. I am holding my nose as I type this, because of that stanky code I posted. I am going to try to cancel the posting on the nntp.perl.org interface but of course the List itself will still see it, unfortunately. Here is a rectified version of the code in question, and my apologies. Subject: Re: name of perl in MakeMaker On Mon, 01 Apr 2002 02:52:20 GMT, [EMAIL PROTECTED] (Stephen Zander) wrote in news:87hemwyvtn.fsf;pobox.com: [...] looking to invoke perl as part of his test scripts and given that the test suite will usually be invoked using FULLPERL, it makes sense to me to use that for any additional perl invocations inside that test suite. Adding the following to Makefile.PL ensures that the tests dance with the perl that brought them. [snip] If the modules has a t/*.t testbed, then the following is required instead: [see original; this may have been mangled / miswrapped by my emailer] sub MY::test_via_harness { my($self, $perl, $tests) = @_; my $_perl = $perl; $_perl = $Is_Win32 ? PERL_DL_NONLAZY=1 $perl : $_perl .= -Mblib; \t$_perl.q! -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) -e '$$ENV{MYPERL}=$perl; use Test::Harness qw(runtests $$verbose); $$verbose=$(TEST_VERBOSE); runtests @ARGV;' !.$tests\n; } with the various tests invoking $ENV{MYPERL} instead of $^X. The above is not guarenteed to work on VMS. It needs some well-placed double quotes. Would this do the trick?: -8 =item test_via_harness Again, this is *not* MM_Unix.pm sub/method, but based on one contributed by Stephen Zander (see test_via_script) on the [EMAIL PROTECTED] List. He notes: If the modules has a t/*.t testbed, then this following is required instead [...] With the various tests invoking $ENV{MYPERL} instead of $^X. The above is not guarenteed to work on VMS. It needs some well-placed double quotes. =cut sub MY::test_via_harness { my($self, $perl, $tests) = @_; my $_perl = $perl; $_perl = $Is_Win32 ? PERL_DL_NONLAZY=1 $perl : $_perl; $_perl.= -Mblib; qq{\t$_perl} .q{ -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \\} .q% -e \$$ENV{MYPERL} = q[% .$perl .q%]; \\% .q% -e use Test::Harness qw(runtests \$$verbose); \$$verbose = $(TEST_VERBOSE); \\% .q% -e runtests @ARGV;% .qq{ $tests\n}; } -8 Thanks very much. I have used your improvements in the [Module::]ExoBuild project I am currently doing. I haven't got a VMS system to test this on and it's [[s/not tested at all/tested to a limited degree/]] yet. OMMV. Just thought it was approximately what you meant it needed in terms of quoting fixes, also I think it is now a bit more readable. It ran correctly in Cygwin bash; the '$'s are escaped correctly for that shell. The module package I tested it on is Compress::Zlib v1.19. Here's what it created in 'Makefile': -8 test_dynamic :: pure_all $(FULLPERLRUN) -Mblib -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \ -e \$$ENV{MYPERL} = q[$(FULLPERLRUN)]; \ -e use Test::Harness qw(runtests \$$verbose); \$$verbose = $(TEST_VERBOSE); \ -e runtests @ARGV; $(TEST_FILES) # [...] test_static :: pure_all $(MAP_TARGET) ./$(MAP_TARGET) -Mblib -I$(INST_ARCHLIB) -I$(INST_LIB) -I$(PERL_ARCHLIB) -I$(PERL_LIB) \ -e \$$ENV{MYPERL} = q[./$(MAP_TARGET)]; \ -e use Test::Harness qw(runtests \$$verbose); \$$verbose = $(TEST_VERBOSE); \ -e runtests @ARGV; $(TEST_FILES) -8 That LOOKS much more like what we want, at least? Soren A -- conway: unit of mind expansion. One Conway == ~20 lines of Perl code found in $CPAN/authors/id/D/DC/DCONWAY, which gives the sensation of your brain being wrapped around a brick, with kiwi juice squeezed on top. -- Ziggy (via Schwern)
Re: name of perl in MakeMaker
Stephen Zander [EMAIL PROTECTED] wrote: Sam Hi all, How do you return the name of perl in your module's Sam Makefile.PL? If you're generating rules for the Makfile that will be produced, don't try to hardcode perl at all. Rather use the PERL Makefile variable that MakeMaker has already gone to great pains to get right for you. OK, I've tried this - the following code is an example of how to get MakeMaker's variables in a Makefile.PL: use ExtUtils::MakeMaker; # If this function is not called manually on older versions of # ExtUtils::MakeMaker, it goes tits up. ExtUtils::MakeMaker::full_setup(); my $mm = MM-new({ 'NAME' = 'Pod::Constants', ... }); open TEMPFILE, t/tempfile or die $!; print TEMPFILE, $mm-{FULLPERL},\n; close TEMPFILE; $mm-flush(); In the test script, you have to open t/tempfile to get the contents. It's a hack, but it works. Tested with 5.00503 and 5.6.1. I fall back to the $Config{perlpath} and $^X variables in the event of a failure with this method. There should be an easier way. Cheers, -- Sam Vilain, [EMAIL PROTECTED] WWW: http://sam.vilain.net/ 7D74 2A09 B2D3 C30F F78E GPG: http://sam.vilain.net/sam.asc 278A A425 30A9 05B5 2F13 Hi, I'm a .signature virus! Copy me into your ~/.signature, please!
Re: name of perl in MakeMaker
On Monday, April 1, 2002, at 09:39 AM, Stephen Zander wrote: Sam == Sam Vilain [EMAIL PROTECTED] writes: Sam Hi all, How do you return the name of perl in your module's Sam Makefile.PL? If you're generating rules for the Makfile that will be produced, don't try to hardcode perl at all. Rather use the PERL Makefile variable that MakeMaker has already gone to great pains to get right for you. I wouldn't say right. Note this comment in the EU::MM_Unix source: # Find Perl 5. The only contract here is that both 'PERL' and 'FULLPERL' # will be working versions of perl 5. In other words, it might find the wrong installed binary if you've got more than one. It does this by searching a list of directories for executables with any of a list of names, including 'perl'. A reasonable approach in most situations is this: use Config; $perl = -X $^X ? $^X : $Config{perlpath}; You might also want to check whether $^X is an absolute path. Sometimes it's not, as when a shebang script is run on some systems. This is a great joy. -Ken
Re: name of perl in MakeMaker
On Mon, Mar 25, 2002 at 09:04:43PM +1100, Ken Williams wrote: use Config; $perl = $Config{perlpath}; This is very wrong. This is what libwww is using; as a result, you cannot test libwww with uninstalled Perl. *At* least use (-x $^X) ? $^X : $Config{perlpath}; I agree that $Config{perlpath} is wrong, but no great right solution seems to present itself. What's a script to do if it wants to invoke the same perl executable that's currently running? In some cases neither $^X or $Config{perlpath} will do the trick. When there is no universal solution, a solution which is at least as good as any other will go. And what I wrote is such a solution. The security-conscious would add is_absolute_path($^X) to -x $^X to avoid writable-current-directory attack. But this looks irrelevant in the context of building a module... Ilya
Re: name of perl in MakeMaker
On Thu, Mar 14, 2002 at 11:38:38AM +0100, Wim Verhaegen wrote: How do you return the name of perl in your module's Makefile.PL? use Config; $perl = $Config{perlpath}; This is very wrong. This is what libwww is using; as a result, you cannot test libwww with uninstalled Perl. *At* least use (-x $^X) ? $^X : $Config{perlpath}; Ilya