Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Why is my test failing?

by jaldhar (Vicar)
on Mar 06, 2008 at 11:00 UTC ( #672428=perlquestion: print w/replies, xml ) Need Help??

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

I decided to update my DateTime::Calendar::Discordian but the CPAN Testers are reporting lots of failures with the new version like e.g. this:
t/04-perl-critic.....................Can't locate Test/Perl/ +in @INC (@INC contains: /usr/home/david/cpantesting/perl-5.10.0/.cpan/build/DateTime-Calendar- +Disc ordian-0.9.5-R6NHvJ/blib/lib /usr/home/david/cpantesting/perl-5.10.0/.cpan/build/DateTime-Calendar- +Disc ordian-0.9.5-R6NHvJ/blib/arch /home/david/cpantesting/perl-5.10.0/lib/5.10.0/i386-freebsd-thread-mul +ti /home/david/cpantesting/perl-5.10.0/lib/5.10.0/i386-freebsd-thread-mul +ti /home/david/cpantesting/perl-5.10.0/lib/5.10.0 /home/david/cpantesting/perl-5.10.0/lib/site_perl/5.10.0/i386-freebsd- +thre ad-multi /home/david/cpantesting/perl-5.10.0/lib/site_perl/5.10.0/i386-freebsd- +thre ad-multi /home/david/cpantesting/perl-5.10.0/lib/site_perl/5.10.0 . /home/david/cpantesting/perl-5.10.0/lib/5.10.0/i386-freebsd-thread-mul +ti /home/david/cpantesting/perl-5.10.0/lib/5.10.0 /home/david/cpantesting/perl-5.10.0/lib/site_perl/5.10.0/i386-freebsd- +thre ad-multi /home/david/cpantesting/perl-5.10.0/lib/site_perl/5.10.0 .) a +t t/04-perl-critic.t line 14. BEGIN failed--compilation aborted at t/04-perl-critic.t line 14. # Looks like your test died before it could output anything. dubious
...on lots of different perl versions and OS's.

The failing test looks like this:

use strict; use warnings; use English qw(-no_match_vars); use Test::More; if ( not $ENV{TEST_AUTHOR} ) { my $msg = 'Author test. Set $ENV{TEST_AUTHOR} to a true value to +run.'; plan( skip_all => $msg ); } eval { use Test::Perl::Critic (-profile => 't/perlcriticrc'); }; if ( $EVAL_ERROR ) { my $msg = 'Test::Perl::Critic required to criticise code'; plan( skip_all => $msg ); } all_critic_ok()

What gives? The eval should catch if Test::Perl::Critic is not installed right?

I am using a similar idiom for tests using Test::Pod and Test::Pod::Coverage and they aren't causing problems.


Replies are listed 'Best First'.
Re: Why is my test failing?
by haoess (Curate) on Mar 06, 2008 at 11:21 UTC
    eval { use Test::Perl::Critic (-profile => 't/perlcriticrc'); };

    What gives? The eval should catch if Test::Perl::Critic is not installed right?

    No. You are using eval BLOCK syntax, so the use statement is executed at compile time. To get this catched use eval STRING as in

    eval "use Test::Perl::Critic (-profile => 't/perlcriticrc')";

    -- Frank

Re: Why is my test failing?
by thospel (Hermit) on Mar 06, 2008 at 11:28 UTC
    It's a bug in the test. use happens at compile time (during the interpretation of the code) and fails at that point. The eval would catch runtime failures, but the code never gets to runtime.

    The test should probably use require and do an import by hand, something like (untested):

    eval { require Test::Perl::Critic; Test::Perl::Critic->import(-profile => 't/perlcriticrc'); ... };
Re: Why is my test failing?
by jaldhar (Vicar) on Mar 06, 2008 at 11:55 UTC

    Doh! thanks haoess and thospel. I was actually using string eval in my other tests but somehow my eyes glazed over that small but crucial difference. A new version of the module will be uploaded shortly.


      somehow my eyes glazed over
      It must have been the hand of Eris touching you.



      A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://672428]
Approved by marto
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2020-06-03 13:57 GMT
Find Nodes?
    Voting Booth?
    Do you really want to know if there is extraterrestrial life?

    Results (24 votes). Check out past polls.