Shawn Sorichetti, God bless his soul, gave me what I'd long wanted: a sample test script for testing Rubric::WebApp using HTTP::Server::Simple and Test::WWW::Mechanize. It wasn't the Mech stuff I was worried about, but the HSS. Shawn gave me two little files to drop in place and see the whole thing work. Now I am set to start testing all kinds of crap!
I got to a point where I wanted to start organizing my test files into directories, and I remembered that while prove can do recursive test files with -r, MakeMaker doesn't use Harness that way by default. Neither Shawn nor Andy had a ready-made solution, so I got a really weird urge to do something silly, and wrote this:
test => { TESTS => join " ", sub { my $w; $w = sub { map { -d $_ ? $w->($_) : /\.t\Z/ ? $_ : () } grep { ! /^\./ } <$_[0]/*> }; $w->("t"); }->() },
Is that missing something? Unless I misinterpret the intent, shouldn’t there be a call that reads a directory’s content somewhere?
And wouldn’t a do {}
block do in place of the outer sub{}->()
? You’re not passing any parameters (which is when that bit of voodoo is useful), after all.
Re:
rjbs on 2005-06-09T12:06:55
A "do" would be better, yes. The something to read the directory content is apparently being eaten by slashcode/html. After the grep is "$_[0]*" in a diamond glob operator.Re:
Aristotle on 2005-06-09T20:35:21
Ah. Try using
<ecode></ecode>
tags for blocks of code, or otherwise, use<
for literal opening angle brackets.Re:
rjbs on 2005-06-09T20:50:03
Aha! Yes, thanks. I don't know why I forgot to use ecode!
I should probably just use File::Find, but I like this silly hack.