Whitehawke has asked for the wisdom of the Perl Monks concerning the following question:

I've finally gotten around to putting a module up on CPAN. I pulled down Test::Prereq in order to check that I had put all the requirements in my PREREQ_PM list. At first I got an odd failure from it, then I got an unhelpful response; this makes me think that I'm using it improperly. Can any more experienced monks steer me to a better FM than I have found thus far?

I had the following two problems:

  1. When I ran the command-line example that was given in the T::P module docs, I was told 'You tried to plan twice!' and it died. Aside from Test::Builder, none of the Test:: modules are included in my module, and I certainly do not call plan()
  2. That having failed, I took the script-based example from the T::P docs and put it in my t/001.t file. That ran, but all it tells me is "Found some missing prereqs". This seems unhelfpul...I rather expected a list.

The module in question is intended to help out with the testing of a CGI via comparing it to known-good output. It was built using the 'modulemaker' script included with ExtUtils::ModuleMaker and uses Module::Build as its build framework.

Replies are listed 'Best First'.
Re: Test::Prereq difficulties
by PodMaster (Abbot) on Mar 04, 2005 at 06:30 UTC
    You should be able to track prerequisites without a module, but if you can't, just grab a copy of Module::ScanDeps and use it to generate a list.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

      There are a lot of things we should be able to do without a module, but that's not reality. Modules like Test::Prereq, Test::Pod, Test::Distribution, and so on help us figure out what we forgot to do.

      You might be able to track prerequisites without a module, but that tasks gets harder when it's more than a couple people working on the code or the code base gets larger. There's no reason to tell someone that they shouldn't use a computer to check their work. :)

      Module::ScanDeps is okay, but it's better to actually run the code and see what it uses rather than parse the code and guess.

      --
      brian d foy <bdfoy@cpan.org>
        There's no reason to tell someone that they shouldn't use a computer to check their work. :)
        It's a good thing I didn't suggest that then ;)
        Module::ScanDeps is okay, but it's better to actually run the code and see what it uses rather than parse the code and guess.
        Sure, but Test::Prereq is overkill.

        MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
        I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
        ** The third rule of perl club is a statement of fact: pod is sexy.

Re: Test::Prereq difficulties
by brian_d_foy (Abbot) on Mar 04, 2005 at 13:13 UTC

    Which version of Test::Prereq are you using? How are you using it? Can you post the script that you wrote using it?

    I'm guessing that your command line was the following, which is a documentation error. prereq_ok() now calls plan() itself, so it doesn't need to call it on the command line too.

    perl -MTest::More=tests,1 -MTest::Prereq -eprereq_ok

    The fix is to just not tell Test::More anything. I've patched the docs for this and sent the new version to CPAN.

    perl -MTest::More -MTest::Prereq -eprereq_ok

    I'm not sure about your second problem since the error message you say yout got isn't anywhere in the current Test::Prereq sources.

    --
    brian d foy <bdfoy@cpan.org>
      Why does it need -MTest::More on the command line? It doesn't seem to be used in the module anywhere and even if it was, you could just do use Test::More inside the module. I tried it without and it worked fine.

      While I'm at, why not add

      sub import { prereq_ok() if (caller())[1] eq '-'; }
      that way someone could just do
      perl -MTest::Prereq

      Useful module (not overkill :)

        You're right: that Test::More is superfluous. I don't know what I was thinking then, but it doesn't make sense to me anymore. I've taken that out completely and fixed up the docs.

        I like the idea of running the test if the module is used from the command line, but it feels slightly odd and anti-DWIM to me. Maybe it won't feel so weird when I upload the next version.

        Thanks :)

        --
        brian d foy <bdfoy@cpan.org>