Slaven, I tried to do what you suggested, but without success:
use strict;
use warnings;
use Test::More;
#
# Skip tests if required modules are not available.
#
if (!eval { require Regexp::Common; 1 }) {
plan skip_all => "Regexp::Common moduled required";
}
if (!eval { require Image::Info; 1 }) {
plan skip_all => "Image::Info moduled required";
}
plan tests => 1;
#
# Load module under test.
#
use Graphics::Fig; # uses the modules checked above
....
When "plan skip_all" is executed, it exits the script without allowing control
to continue after the statement. So my expectation was that the "use
Graphics::Fig" below would not be executed if one of the tests above failed.
But it seems that perl looks ahead and processes all "use" directives before
starting execution of the script; therefore, if Graphics::Fig has unsatisfied
dependencies, the script blows up before executing the module check code at the
top.
I tried to force the execution order by putting the module tests inside a BEGIN
block. That also didn't work.
Scott
From: Slaven Rezic <[email protected]>
To: Scott Guthridge via cpan-testers-discuss <[email protected]>;
Scott Guthridge <[email protected]>
Sent: Wednesday, June 14, 2017 10:37 AM
Subject: Re: tests failing due to dependency on Regexp::Common
Something like this could work:
use Test::More;
plan skip_all => "Regexp::Common required for test" if !eval { require
Regexp::Common; 1 };
plan tests => ...;
> Scott Guthridge via cpan-testers-discuss <[email protected]> hat
> am 14. Juni 2017 um 01:16 geschrieben:
>
> In Graphics::Fig v1.0.1, several runs are failing due to a missing dependency
> on the Regexp::Common module:
>
> # Tried to use 'Graphics::Fig'.
> # Error: Can't locate Regexp/Common.pm in @INC (you may need to install
> the Regexp::Common module) (@INC contains:
> /home/cpan/pit/bare/conf/perl-5.18.2/.cpanplus/5.18.2/build/NYePZvq91K/Graphics-Fig-v1.0.1/blib/lib
>
> /home/cpan/pit/bare/conf/perl-5.18.2/.cpanplus/5.18.2/build/NYePZvq91K/Graphics-Fig-v1.0.1/blib/arch
>
> /home/cpan/pit/bare/conf/perl-5.18.2/.cpanplus/5.18.2/build/NYePZvq91K/Graphics-Fig-v1.0.1/blib/lib
>
> /home/cpan/pit/bare/conf/perl-5.18.2/.cpanplus/5.18.2/build/NYePZvq91K/Graphics-Fig-v1.0.1/blib/arch
> /home/cpan/pit/bare/perl-5.18.2/lib/site_perl/5.18.2/x86_64-linux
> /home/cpan/pit/bare/perl-5.18.2/lib/site_perl/5.18.2
> /home/cpan/pit/bare/perl-5.18.2/lib/5.18.2/x86_64-linux
> /home/cpan/pit/bare/perl-5.18.2/lib/5.18.2 .) at
> /home/cpan/pit/bare/conf/perl-5.18.2/.cpanplus/5.18.2/build/NYePZvq91K/Graphics-Fig-v1.0.1/blib/lib/Graphics/Fig/Parameters.pm
> line 23.
> # BEGIN failed--compilation aborted at
> /home/cpan/pit/bare/conf/perl-5.18.2/.cpanplus/5.18.2/build/NYePZvq91K/Graphics-Fig-v1.0.1/blib/lib/Graphics/Fig/Parameters.pm
> line 23.
> # Compilation failed in require at
> /home/cpan/pit/bare/conf/perl-5.18.2/.cpanplus/5.18.2/build/NYePZvq91K/Graphics-Fig-v1.0.1/blib/lib/Graphics/Fig.pm
> line 25.
> # BEGIN failed--compilation aborted at
> /home/cpan/pit/bare/conf/perl-5.18.2/.cpanplus/5.18.2/build/NYePZvq91K/Graphics-Fig-v1.0.1/blib/lib/Graphics/Fig.pm
> line 25.
> # Compilation failed in require at t/arc.t line 15
>
> Is there a way to list specific module dependencies in the test
> configuration? Or should I recode my module to not depend on that module?
>
> Thanks,
> Scott