Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Factory classes in Perl (updated)

by hippo (Bishop)
on Jan 09, 2021 at 11:46 UTC ( [id://11126649]=note: print w/replies, xml ) Need Help??


in reply to Re: Factory classes in Perl (updated)
in thread Factory classes in Perl

I'd be genuinely curious if there are other useful uses for the "recommends" and "suggests" relationships of CPAN::Meta::Spec.

You might consider the recommendation or suggestion of optional modules used in the test suite. Often previously I have found that a dist will require various modules for testing which themselves have long dependency chains. This is fine if you want 100% coverage but a lot of the time I (as a user) just want to be able to install the module, test the essential components and be done without downloading lots of modules for the test suite that I might never use again.


🦛

Replies are listed 'Best First'.
Re^3: Factory classes in Perl
by haukex (Archbishop) on Jan 09, 2021 at 14:13 UTC

    None of my modules are large enough to have a massive test suite, but I imagine in a large test suite you're right that it might be possible to make some tests optional. I personally try not to require a ton of modules for testing (except in my author tests), i.e. the same policy as for the modules themselves (e.g. use Moo instead of Moose when possible and so on). Also, though I'm not sure at the moment how the different CPAN clients handle this, I believe that TEST_REQUIRES dependencies are the ones that don't need to be installed into the user's environment.

    Update: In fact, as an example, because I really only need one functionality from Test::Exception Test::Fatal and Test::Warnings each, I now quite simply inline that:

    sub exception (&) { eval { shift->(); 1 } ? undef : ($@ || die) } sub warns (&) { my @w; { local $SIG{__WARN__} = sub { push @w, shift } +; shift->() } @w }

      I have some huge test suites that have a number of needed modules that dwarfs that of the software itself.

      I mean the software installs in seconds, but if I force-required all of the modules needed to test the entire application at the level I need it tested before release, the install can take over 30 minutes (or longer).

      What I do is make the tests optional, if the needed modules for testing aren't installed. If a test has all needed modules, they run. I can have many of these scenarios in a single test file sometimes.

      I ensure that ALL tests are run on several versions of Perl locally (with pre-installed test modules), and also put into my CI configuration the cpanm install commands for all of the test modules, so that they run on various Perls on several OSs there as well.

      The Makefile.PL that is uploaded to the CPAN contains only the distributions that the software needs to run, plus any basic ones that the build (ie. test) phase needs. By running all tests locally as well as CI, I can be quite reasonably sure that the software will work for my users too.

      The only time I won't bypass an install of a large module or collection of modules used for testing, is if the part of code that's being tested is in the critical path, that is it is a critical piece of functionality that if tests fail, the software may be rendered inoperable, or worse. I need these tests to pass on each client device, not just on a selection of Perls and OSs upstream somewhere.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11126649]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (7)
As of 2024-03-28 12:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found