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 ]

DAxelrod (4649)

DAxelrod
  (email not shown publicly)

I'm interested in hard problems.

Recently, I've started thinking a lot about what CP6AN might look like.

Class::MOP and the Perl 6 Metamodel make me more excited than I'd like to admit.

Also expect occasional wordy technology-related rantings.

Journal of DAxelrod (4649)

Saturday September 16, 2006
01:53 PM

Testing Installed Modules: Opening a Can of Worms

[ #31018 ]

Ovid recently asked what should be a simple question: How should we install tests along with modules?

Of course, this is not a simple question at all and breaks down into several distinct problems. The first is actually "How do we test an installed module?"

kwilliams responded with the brilliant idea of a Module::Build retest action, that would look for modules in @INC instead of blib.

Unfortunately, this doesn't completely solve our first problem.

Why? Because way too many tests are written with the assumption that they will be running from within an unpacked module distribution. Which means they require context outside of the installed .pm files.

Off the top of my head, the kinds of tests that have this problem include

  • Tests that pull in specific files from the distribution
    • Tests that pull in test modules not in blib
    • Tests for scripts installed with the module
    • Tests that pull in data files (which may end up being installed)
  • Tests that depend on the whole distro structure
    • Test::Signature
    • Test::Distribution
    • Test::Pod
    • Test::Pod::Coverage
    • tests that rely on the MANIFEST
    • tests that scan files for spelling errors, minimum versions, or prereqs

You could argue that any of these that are abstracted into Test::Whatever modules have enough of a layer of indirection to account for however you test installed modules. But I think that misses the point. A list that large is not evidence of special cases. It's evidence that it's important for tests to have more than the .pm alone.

One solution that sucks could be a way of marking which tests assume they're being run in a distribution and which ones don't care. That would be horribly tedious.

Maybe this is evidence that we need a metadata database to go with our installed modules. We already have a PACKLIST that sorta kinda serves as an installed module database. The problem is, now we need an API for tests to query that database.

Maybe we're going about this wrong. Tests need a distribution. Modules work in a distribution and out of a distribution. It's common to develop modules inside a distribution.

Why not install an entire module distribution?

Have a lib-like directory which is searched for entire distributions rather than just .pm files. When you use a module, it will actually be pulled from its distribution.

Running modules from within distributions? Doesn't that sound like PAR?

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.
  • Because way too many tests are written with the assumption that they will be running from within an unpacked module distribution.

    Which is exactly the situation that the retest feature in Module::Build assumes, so I don’t quite see why this is a problem.

    • The problem is that installed modules have more to them than the .pm files, and those are basically the only parts of your installation you're going to be testing when you use retest.

      Tests for scripts will be tests on the scripts in the distribution, not the ones installed. Likewise for all the other things that a distro can have.

  • It was my original request. I want to make sure that things still work even though I've upgraded a module low down in the dependency tree. I don't want to solve this in every case. I don't want the moon on a stick. I just want something simple, like copying t/* somewhere during install. I was afraid of posting about it because I knew people would go overboard and get philosophical. And look what happened when Ovid mentioned it...
    • I'm interested in the future of the module ecosystem.

      This was an opportunity for me to get philisophical, but it wasn't your fault. :)