Re: Trying to spear a phalanx shield for pod
On Tuesday, Oct 28, 2003, at 23:48 Europe/London, Michael G Schwern wrote: On Tue, Oct 28, 2003 at 08:17:24PM +, Adrian Howard wrote: This may be a dim question but why scan blib and lib? [snip] my $blib = File::Spec-catfile(qw(blib lib)); [snip] That's not blib and lib, that's a cross platform way of saying: my $blib = 'blib/lib'; If any more proof were needed that I am a complete idiot :-/ (note to self: remember to actually read the fardling code next time - and don't write email on the train home) embarrassed Adrian
Re: Trying to spear a phalanx shield for pod
On Friday, Oct 24, 2003, at 14:23 Europe/London, Andrew Savige wrote: I'm about to add a POD test program to my phalanx distro. Before I do that, just want to check I'm using the best model. I plan on using the one from WWW::Mechanize (shown below) -- unless someone can suggest a better model. [snip] This may be a dim question but why scan blib and lib? [snip] my $blib = File::Spec-catfile(qw(blib lib)); [snip] Wouldn't everything in lib be in blib at test time? Also, isn't there the possibility that people might transform illegal POD in lib to legal POD in blib using .PL scripts at build time? Adrian
Re: Trying to spear a phalanx shield for pod
On Tue, Oct 28, 2003 at 08:17:24PM +, Adrian Howard wrote: This may be a dim question but why scan blib and lib? [snip] my $blib = File::Spec-catfile(qw(blib lib)); [snip] That's not blib and lib, that's a cross platform way of saying: my $blib = 'blib/lib'; Wouldn't everything in lib be in blib at test time? Also, isn't there the possibility that people might transform illegal POD in lib to legal POD in blib using .PL scripts at build time? Yes. The could also put VB scripts into .pod files and smear mayonase on your keyboard. :) For those special cases they can write special case code to skip those files that should not be checked. -- Michael G Schwern[EMAIL PROTECTED] http://www.pobox.com/~schwern/ The Power almighty rests in this Lone Ring. The Power, alrighty, for doing your Own Thing. If broken or busted, it cannot be remade. If found, send to Sorhed (the postage is prepaid). -- Bored of the Rings
Re: Trying to spear a phalanx shield for pod
On Sun, Oct 26, 2003 at 04:45:48PM +1100, Andrew Savige wrote: Michael G Schwern wrote: Since skip_all will exit immediately you can fold that big everything inside the else block away. eval 'use Test::Pod'; my $have_testpod = !$@ and $Test::Pod::VERSION = 0.95; plan skip_all = Test::Pod v0.95 required for testing POD unless $have_testpod; my @files; my $blib = File::Spec-catfile(qw(blib lib)); ... There is a misprint in this line: my $have_testpod = !$@ and $Test::Pod::VERSION = 0.95; It should read: my $have_testpod = !$@ $Test::Pod::VERSION = 0.95; I deliberately used and instead of . I'd noticed the original was using explicit parens to disambiuate the precendence to make sure there was no chance of it accidentally evaluating as: (!$@ $Test::Pod::VERSION) = 0.95 for those of us that don't have the symbol table memorized. Instead of parens, I went with 'and'. But looking at the precdence table, either version will work. Based on the excellent work from Lester Schwern, I could not restrain myself from shortening this a little more (since it will be included in many distributions). The logic escapes me. Clarity is more important than length if you're going to be sticking this code all over the place. But if we're going to encourage people to copy this code, Test::Pod should probably just have a subroutine to do this for you. That's what libraries are for! My current short version is: use Test::More; use File::Spec; use File::Find; use strict; eval 'use Test::Pod'; plan skip_all = Test::Pod v0.95 required for testing POD if $@ || $Test::Pod::VERSION 0.95; my @files; find( sub {push @files, $File::Find::name if /\.p(?:l|m|od)$/}, File::Spec-catfile( qw(blib lib) ) ); plan tests = scalar @files; foreach my $file (@files) { pod_file_ok($file) } Two questions: 1) Is using $File::Find::name portable on VMS and Mac OS? (I'm confused about File::Find's use of 'Unix' names). Since you're just looking at the end of the filename, yes. It doesn't matter if the path is Unixy or native. In fact, since the directory name doesn't matter you can match against $_. 2) Which is preferred: eval 'use Test::Pod'; or: eval { require Test::Pod }; ... Test::Pod-import; or does it not matter? Doesn't really matter. If I was going to be strict about it I'd say do this: BEGIN { eval { require Test::Pod }; plan skip_all = Test::Pod v0.95 required for testing POD if $@ || $Test::Pod::VERSION 0.95; Test::Pod-import; } or this: BEGIN { eval q{ use Test::Pod 0.95 }; plan skip_all = Test::Pod v0.95 required for testing POD if $@; } so that the functions are imported at compile time. This means you can use them without parens. I like the latter since its most straight forward and concise. -- Michael G Schwern[EMAIL PROTECTED] http://www.pobox.com/~schwern/ WOOHOO! I'm going to Disneyland! http://www.goats.com/archive/980805.html
Trying to spear a phalanx shield for pod
I'm about to add a POD test program to my phalanx distro. Before I do that, just want to check I'm using the best model. I plan on using the one from WWW::Mechanize (shown below) -- unless someone can suggest a better model. Is it worth trying to agree on a de facto standard name for such a beast: 99-pod.t/99_pod.t/99.pod.t/99pod.t? use Test::More; use File::Spec; use File::Find; use strict; eval { require Test::Pod; }; my $ok = !$@ ($Test::Pod::VERSION = '0.95'); if (!$ok) { plan skip_all = Test::Pod v0.95 required for testing POD; } else { Test::Pod-import; my @files; my $blib = File::Spec-catfile(qw(blib lib)); find( sub {push @files, $File::Find::name if /\.p(l|m|od)$/}, $blib); plan tests = scalar @files; foreach my $file (@files) { pod_file_ok($file); } } /-\ http://personals.yahoo.com.au - Yahoo! Personals New people, new possibilities. FREE for a limited time.
Re: Trying to spear a phalanx shield for pod
Is it worth trying to agree on a de facto standard name for such a beast: 99-pod.t/99_pod.t/99.pod.t/99pod.t? Personally, I'd just as soon not have it be one of the numeric ones. It doesn't matter what order it's run in. xoa -- Andy Lester = [EMAIL PROTECTED] = www.petdance.com = AIM:petdance