Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

BooK (2612)

BooK
  {book} {at} {cpan.org}
http://paris.mongueurs.net/
Yahoo! ID: philippe_bruhat (Add User, Send Message)

Obfuscation [plover.com]. Pink [axis-of-aevil.net]. HTTP::Proxy [cpan.org]. YEF [yapceurope.org]. Fishnet [perl.org]. Kapow [cpan.org]. Cog's [perl.org] bitch [cpan.org]. Invitation [perl.org]. White [perl.org] Camel [perl.org]. Nuff' said.

Journal of BooK (2612)

Monday October 11, 2004
04:31 AM

Checking for Test::More

[ #21290 ]

Recently, I've taken the habit (not in my CPAN modules, though) to add the following snippet at the beginning of all my test scripts:

BEGIN {
    eval { require Test::More; }; # and other Test:: modules
    print "1..0 # Skip Test::More missing\n", exit if $@;
}

This is because I do not expect the people who install those modules/scripts to run the test suite, and I don't want the installation process to whine about Test::More missing (if it's in the Makefile.PL) and stop and sulk.

I think that the Test:: modules should not be part of the prerequisites for using a module. Am I right?

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Isn't Test::More one of those modules that every Perl installation should have? So the sooner someone is "forced" to install it the better, IMHO.

    As dependencies go, isn't Test::More pure Perl, so it should install everywhere without problem?
  • while I'm a guity as anyone for having done this in the past, I've not come to support the position that test modules should not be prerequisites a la PREREQ_PM despite the ubiquity of Test::More - there is a large difference between the test environment and the code itself, and making it impossible to build and install a module when test environment dependencies are missing just seems wrong.

    but another solution to using a BEGIN block in each test file is to override the test target in the Makefile by cr
  • I think that the Test:: modules should not be part of the prerequisites for using a module. Am I right?

    If you can't run the tests, then how do you know that your users can actually use the module?

    --

    --
    xoa

    • Like he said, he doesn't do this for modules. That's a different world with different expectations.
    • In fact, the conclusion came to me after posting that entry:

      It would be nice to separate the test prerequisites and the usage prerequisites.

      I've just been told (hi Maddingue [perl.org]!) that Module::Build [cpan.org] allows this (well build_requires is not quite the same as a test_requires, but probably close enough).

  • In fact, I think what you want is something similar to the build_requires in Build.PL but for the tests only: tests_requires. Maybe you could ask Ken Williams to add this for the next release of Module::Build?
    --
    Close the world. txEn eht nepO
  • I think Test::Simple should be marked as a dependency. It really is needed to run the basic tests to confirm the module works. If you need other more esoteric Test::* modules then test scripts which degrade gracefully may be a good idea. Unfortunately, that would not allow you to take the fullest advantage of the the service provided by the wonderful CPAN-Testers team.

    On a related note, many CPAN modules are also repackaged in RPM, .deb and related formats. These files are easier for Joe Public to ins

    • Unfortunately, that would not allow you to take the fullest advantage of the the service provided by the wonderful CPAN-Testers team.

      Well, I take for granted the fact that all CPAN testers have at least all the Test::* modules installed.

      • I take for granted the fact that all CPAN testers have at least all the Test::* modules installed

        Yes, but surely that's largely as a result of those modules being listed as prerequisites in the distributions being tested.