Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Re: Optional modules for tests?

by sutch (Curate)
on Sep 07, 2003 at 02:21 UTC ( #289527=note: print w/ replies, xml ) Need Help??


in reply to Re: Optional modules for tests?
in thread Optional modules for tests?

Thanks for the response.

I've been experimenting with this and have minimized my test code to the following:

use Test::More tests => 1; SKIP: { eval{ require Data::Dummy }; skip "Data::Dummy not installed", 2 if $@; ok( 1 ); }
This works fine when the required module is present, but in the case of a non-existant module (such as with the above Data::Dummy), the following is reported:
C:\>nmake test Microsoft (R) Program Maintenance Utility Version 1.50 Copyright (c) Microsoft Corp 1988-94. All rights reserved. C:\Perl\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_harn +ess(0, 'blib\lib', 'blib\arch')" t\test.t t\test....# Looks like you planned 1 tests but ran 1 extra. t\test....dubious Test returned status 1 (wstat 256, 0x100) DIED. FAILED test Failed 0/1 tests, 100.00% okay (less 2 skipped tests: -1 okay, + -100.00%) Failed Test Stat Wstat Total Fail Failed List of Failed ---------------------------------------------------------------------- +--------- t\test.t 1 256 1 0 0.00% 2 subtests skipped. Failed 1/1 test scripts, 0.00% okay. -1/1 subtests failed, 200.00% oka +y. NMAKE : fatal error U1077: 'C:\WINDOWS\system32\cmd.exe' : return code + '0x2' Stop.
I don't understand why this would complain of skipping two subtests, nor why it says that I planned 1 test but ran 1 extra. Is this what normally happens when tests are skipped?


Comment on Re: Re: Optional modules for tests?
Select or Download Code
Re: Re: Re: Optional modules for tests?
by tachyon (Chancellor) on Sep 07, 2003 at 15:12 UTC
    skip "Data::Dummy not installed", 2 if $@; # ^ ^ # MESSAGE, NUM_TESTS_TO_SKIP

    You are only skipping 1 test but you are telling Test::More you are skipping 2 but your plan was only to do 1 test.....

    skip "Data::Dummy not installed", 1 if $@; ^ ^

    Will work just fine.....I even tested it ;-) Test::Harness hates plan != number of tests reported. See my Autogenerate Test Scripts for a neat little widget that will re-number your tests and fix your plan as well as writing most of the Test code for you.

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (21)
As of 2015-07-01 15:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (5 votes), past polls