Fwd: how to detect that we"re running under CPAN::Testers?

Fwd: how to detect that we"re running under CPAN::Testers?

am 12.01.2006 01:52:24 von Tyler

Ron Savage suggested that the ideal way to handle the "end user vs.
autotester" scenario was to encourage the autotesters to install
DBD::SQLite2 (or perhaps set a valid DBI_DSN) for the testing.
testers.cpan.org's existant autotest system doesn't seem to have a way to
tell them this beyond an actual dependancy, neither does
ppm.activestate.com. Even worse (well better from a QA point of view i
guess), ppm.activestate.com won't generate a .ppd for a package with failing
tests; an ActivePerl user can only "ppm install" packages whose tests all
pass.

As a start to solve/workaround this problem, I've sent the following
email to perl-qa@perl.org with the hope that there is a real solution in
place (or at least, somebody's had to deal with this before):

----- Forwarded message from Tyler MacDonald -----

=46rom: Tyler MacDonald
Subject: how to detect that we're running under CPAN::Testers?
To: perl-qa@perl.org

Hello,

Is there any way to tell if my package is being tested automatically
under CPAN::Testers? Here's the situation:

I have a DBI extension (DBIx::Transaction) whose unit tests
currently depend on a valid DSN being available. SQLite makes a good testbed
for "mock" databases, so if DBD::SQLite2 is available, my module defaults to
testing against a temporary database using that. Thus, DBIx-Transaction-0.04
depends on DBD::SQLite2 *unless* the DBI_DSN environment variable is set to
a non-SQLite2 driver. If DBI_DSN is set to an empty string, the tests do not
run at all.

Some people think that in a perfect world, end users should not be
made to install DBD::SQLite2 by default. I'm leaning towards that as well;
less bloat is good.

However, when these packages are being auto-tested as part of the
perl QA effort (and possibly for packaging for use in ActivePerl on
ppm.activestate.com as well), I'd like my Makefile.PL to notice this and
depend on DBD::SQLite2 after all, so that the tests will be run and we have
an assurance that the package works.

Any thoughts/ideas?

Thanks,
Tyler



----- End forwarded message -----

Re: Fwd: how to detect that we"re running under CPAN::Testers?

am 12.01.2006 02:38:29 von mlists

> Is there any way to tell if my package is being tested automatically
> under CPAN::Testers? Here's the situation:

I've never used that module but this should work:

if(exists $INC{'CPAN/Testers.pm'}) {
print "I am probably running under CPAN::Testers\n";
}
else {
print "I am probably *NOT* running under CPAN::Testers\n";
}

That should do what you want if I'm understanding your goal right
*unless* CPAN::Testers has been used but is not actually running the
test that includes the above logic.

Just my .02 about "detecting' it. I'd say the best thing to do is just
write good tests that pass regardless:

eval 'use Foo::Bar';

if($@) {
pritn "Skipping Foo::Bar test since its not installed apparently";
return 1;
}
else {
# run Foo::bar tests
}

then it doesn't matter whose using what where and when because you have
tests that are run if necessary and skipped (but not "failed") otherwise