> On Jan 30, 2017, at 8:16 AM, Nigel Horne <n...@bandsman.co.uk> wrote:
> 
> On 1/30/17 12:09 AM, Jim Turner via cpan-testers-discuss wrote:
>> Greetings,
>> 
>>      I've released a new module to CPAN that requires a working internet 
>> connection to pass it's test harness (it's only function is to retrieve 
>> certain data from specific types of internet sites.  It's failing pretty 
>> much across testing platforms indicating that it's not able to fetch any 
>> data.  How can this be addressed in my test harness?
>> 
>> Regards,
>> 
>> Jim
> 
> Jim:
> 
> Put this into your Makefile.PL:
> 
> use IO::Socket::INET;
> 
> my $s = IO::Socket::INET->new(
>        PeerAddr => 'www.google.com:80',  # Choose the site and port number 
> that you want to ensure is working
>        Timeout => 10
> );
> unless($s) {
>        die '...Insert module name here.... needs a permanent connection to 
> the Internet';
> }

You shouldn't put this in your Makefile.PL, as you shouldn't assume the current 
state (and all future states) of Internet connectivity. You can test to ensure 
that the Internet is reachable during your tests, though, using the same kind 
of mechanism. This is even wrapped up in a module: Test::RequiresInternet. If 
you use that module in your test files that require Internet access, the tests 
will be skipped if the Internet is not available (but make sure to test for the 
site you want, and not just a random Internet site).

I would also make as much of the tests as I could not require Internet, so as 
to maximize the effectiveness of CPAN Testers. 

Doug Bell
d...@preaction.me

Reply via email to