<?xml version="1.0" encoding="windows-1252"?>
<node id="689911" title="Issues when testing module loading" created="2008-06-03 11:30:38" updated="2008-06-03 07:30:38">
<type id="115">
perlquestion</type>
<author id="194370">
skx</author>
<data>
<field name="doctext">
&lt;p&gt;I've been a long-term user of test cases for my own code, as that gives me confidence that my code is good - or at the very least that changes I introduce haven't broken things too much!&lt;/p&gt;
&lt;p&gt;My test-cases, in general, have been fairly straightforward in nature, and have worked without issues.  As a matter of course I try to document the requirements of my code via a test case &lt;tt&gt;modules.t&lt;/tt&gt;, which should ensure that anybody who can make the test case run successfully (via "make test") has all the modules required.&lt;/p&gt;
&lt;p&gt;Here is an explicit example:&lt;/p&gt;
&lt;code&gt;
#!/usr/bin/perl -w -I..
#
#  Test that all the Perl modules we require are available.
#  (This list is automatically generated.)

use Test::More qw( no_plan );

# ...

BEGIN{ use_ok( 'CGI' ); }
require_ok( 'CGI' );

BEGIN{ use_ok( 'Date::Format' ); }
require_ok( 'Date::Format' );

BEGIN{ use_ok( 'POSIX' ); }
require_ok( 'POSIX' );

# ...
# ...
&lt;/code&gt;
&lt;p&gt;This test is part of a series which runs, via cron, on a daily basis.  Unfortunately the combination of modules which I'm testing for give me a whole bunch of spam on STDERR:&lt;/p&gt;
&lt;code&gt;
skx@gold:~$ perl t.t &gt; /dev/null
Subroutine main::ctime redefined at (eval 4) line 2
Prototype mismatch: sub main::ctime ($;$) vs none at (eval 4) line 2
Subroutine main::strftime redefined at (eval 4) line 2
Prototype mismatch: sub main::strftime ($\@;$) vs none at (eval 4) line 2
Subroutine main::asctime redefined at (eval 4) line 2
Prototype mismatch: sub main::asctime (\@;$) vs none at (eval 4) line 2
&lt;/code&gt;
&lt;p&gt;So, my question.  Is it possible for me to avoid these errors whilst still working in the "standard" way when it comes to using Test::More and testing module availability?&lt;/p&gt;
&lt;p&gt;(Certainly I accept that making my crontab entry throw away STDERR would solve my immediate problem, but it might hide things from me in the future.)&lt;/p&gt;
&lt;!-- Node text goes above. Div tags should contain sig only --&gt;
&lt;div class="pmsig"&gt;&lt;div class="pmsig-194370"&gt;
&lt;a href="http://www.steve.org.uk/"&gt;Steve&lt;/a&gt;&lt;br/&gt;
-- &lt;br/&gt;

&lt;/div&gt;&lt;/div&gt;</field>
</data>
</node>
