[352] t/*.t use() statements (and this $ENV{PERL_CORE} thing, (and the shebang))
Eric Wilhelm
scratchcomputing at gmail.com
Fri Aug 31 08:54:23 BST 2007
We should be using the Test::More which is in t/lib now. I needed to
make sure that all of the tests do "use lib 't/lib'" before loading
Test::More.
Further, I wanted to cleanup the use() statements in general to group
things together a bit. I'll explain the rationale, then later I have a
question about the $ENV{PERL_CORE} thing and the shebang.
What I came up with was essentially like this example:
#!/usr/bin/perl -w
use strict;
use lib 't/lib';
use Test::More 'no_plan';
use IO::Capture;
use File::Spec;
use File::Basename;
use TAP::Parser;
use TAP::Parser::Iterator;
That is, we have these groups of statements with blank lines between
them:
1) the shebang
2) strict+lib
3) Test::More (and the plan (if it is feasible yet))
(also, IO::Capture and other stuff in t/lib)
4) Core modules used by this test
5) Project (TAP::Parser) modules used by this test
The logic is that we need strict (so might as well get it out of the way
first), t/lib before Test::More, and Test::More before trying (and
possibly failing) to load anything which is under test.
The core modules (#4) could go either way. Possibly, they should go
before "use lib 't/lib'", but I'm settling for "at least having groups"
at this point.
Now, the shebang line. Should it be:
#!/usr/bin/perl -w
#!perl -w
and/or "-wT" (or something else entirely) ?
Finally, what's the deal with these bits?
BEGIN {
if ( $ENV{PERL_CORE} ) {
chdir 't';
@INC = '../lib';
}
else {
unshift @INC, 't/lib';
}
}
I'm guessing that they should be everywhere if they are anywhere, and
they were not everywhere, so they are now nowhere. If they need to be
everywhere, it should be trivial to do that (though the few I've seen
have variations, so someone will have to explain the goal to me.)
--Eric
--
Moving pianos is dangerous.
Moving pianos are dangerous.
Buffalo buffalo buffalo buffalo buffalo buffalo buffalo.
---------------------------------------------------
http://scratchcomputing.com
---------------------------------------------------
More information about the tapx-dev
mailing list