Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
My question is in the context of testing modules using Test::More and Test::Harness. Let's suppose you want to write a test to use a CPAN module (not the module being tested), but if it's not available on the site where the test is run, to gently skip one or more tests (up to or including every test in the script).

use_ok() does not seem to be the answer. It's a test in itself, which I don't want. It seems aimed at loading the module to be tested, not a module to be used for the test.

It seems a simple enough task, but I get very perplexing results. Trying this sample test script

use strict; use warnings; use Test::Weaken 0.002002; use Test::More tests => 1; pass("Just so I have a test in the example");
with perl 4monks.t, I get
1..1 ok 1 - Just so I have a test in the example
But using the test target of an ExtUtils-MakeMaker generated Makefile, I get:
t/4monks......Test::Weaken does not define $Test::Weaken::VERSION--ver +sion check failed at t/4monks.t line 4. BEGIN failed--compilation aborted at t/4monks.t line 4. t/4monks......dubious + Test returned status 2 (wstat 512, 0x200)
Seems as if Test::Harness can't find a VERSION number which a raw perl command had no trouble finding. (If you suspect I'm doing something wrong in Test::Weaken 0.002002, it's on CPAN for your inspection.)

I've tried some eval trickery, but that this problem with the mysterious disappearing VERSION number so far has defeated me.


In reply to Skipping tests if a module is not available by Jeffrey Kegler

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found