Skip Menu |

This queue is for tickets about the LWP-Online CPAN distribution.

Report information
The Basics
Id: 112728
Status: new
Priority: 0/
Queue: LWP-Online

People
Owner: Nobody in particular
Requestors: KENTNL [...] cpan.org
Cc: ribasushi [...] leporine.io
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.08
Fixed in: (no value)



Subject: Feature request: Add NO_NETWORK_TESTING support

There's a growing use of the env-var NO_NETWORK_TESTING to communicate "hey, the internet may or may not exist, but you don't even have permission to check" to tests.

 

Most people are using https://metacpan.org/source/MALLEN/Test-RequiresInternet-0.05/lib/Test/RequiresInternet.pm  for this goal, but a simple patch could extend this feature to existing users of LWP::Online https://metacpan.org/requires/distribution/LWP-Online?sort=[[2,1]]&size=500

At least, for the "skip_all" case its straight forward, for the "manually call online()", not sure.

Its *probably* safe to put the ENV check inside "online", but that has a limitation:

 

- skip_all works in tests and tests only, and consumers expect it to work in tests, and so testing related ENV vars are applicable.

- *outside* tests, the relevance of NO_NETWORK_TESTING becomes less clear.

Subject: env_no_network.patch
diff -Naur LWP-Online-1.08/lib/LWP/Online.pm LWP-Online-1.08b/lib/LWP/Online.pm --- LWP-Online-1.08/lib/LWP/Online.pm 2011-07-08 07:02:25.000000000 +0000 +++ LWP-Online-1.08b/lib/LWP/Online.pm 2016-03-06 06:20:12.351333667 +0000 @@ -167,6 +167,9 @@ my @functions = grep { $_ ne ':skip_all' } @_; if ( @functions != @_ ) { require Test::More; + if ( $ENV{NO_NETWORK_TESTING} ) { + Test::More->import( skip_all => 'NO_NETWORK_TESTING set' ); + } unless ( online() ) { Test::More->import( skip_all => 'Test requires a working internet connection' ); } diff -Naur LWP-Online-1.08/t/02_main.t LWP-Online-1.08b/t/02_main.t --- LWP-Online-1.08/t/02_main.t 2011-07-08 07:02:25.000000000 +0000 +++ LWP-Online-1.08b/t/02_main.t 2016-03-06 06:14:41.521243616 +0000 @@ -7,7 +7,12 @@ $| = 1; $^W = 1; } - +BEGIN { + if ( $ENV{NO_NETWORK_TESTING} ) { + require Test::More; + Test::More->import('skip_all', "NO_NETWORK_TESTING set"); + } +} use Test::More tests => 6; use LWP::Online 'online', 'offline';