no net access by default

no net access by default

am 31.12.2004 17:30:12 von Gabor

A couple of days ago, while trying to run automated test for libwww
some of the live tests failed. Probably due to network problems
or due to outages on the targeted web sites.
BTW These were some of the live/jigsaw test.


Some people are installing libwww-perl in environments
where it is forbidden to access outside site so even checking
network availability by looking at google.com can be problematic.

I'd like to suggest to change the default behaviour not to
access anything outside the computer.

Ask the user if she wants to run the external test and only
then check if there is a connection at all.

I think even the question should default to no external access
so automated installation won't automatically fail if they
are running without access to Google.

Please let me know what do you think.

Anyway, included a patch against CVS that implements this behaviour.

regards
Gabor


--- lwp5/Makefile.PL 2004-11-30 13:51:58.000000000 +0200
+++ libwww-perl/Makefile.PL 2004-12-31 18:28:20.000000000 +0200
@@ -18,11 +18,12 @@
# option. This is for those that don't want to mess with the configuration
# section of this file.
use Getopt::Std;
-use vars qw($opt_n);
-unless (getopts("n")) {
- die "Usage: $0 [-n]\n";
+use vars qw($opt_n $opt_l);
+unless (getopts("nl")) {
+ die "Usage: $0 [-n] [-l]\n";
}
@programs_to_install = () if $opt_n || grep /^LIB=/, @ARGV;
+my $dolive = $opt_l;

# Check if we should try to run tests that talk to ourself
system(qq("$^X" talk-to-ourself));
@@ -40,6 +41,19 @@
}

# Check if we should try to run the live tests
+unless ($dolive) {
+ unlink("t/live/ENABLED");
+ print < + Some of the tests interact with websites such as Google,
+ in addition to its own internal tests. If you are not connected to the
+ Internet or if those sites have changed these test might fail.
+
+EOT
+ if ( prompt("Do you want to enable these tests?", "n") =~ /^y/i ) {
+ $dolive = 1;
+ }
+}
+
open(CHANGES, "Changes") || die "Can't open Changes: $!";
my $release_date;
while () {
@@ -54,7 +68,7 @@

my $some_time_ago = sprintf "%04d-%02d-%02d",
sub { ($_[5]+1900, $_[4]+1, $_[3])}->(localtime(time - 45 * 24*60*60));
-if ($some_time_ago lt $release_date) {
+if ($some_time_ago lt $release_date and $dolive) {
# Check if we have internet connection
require IO::Socket;
my $s = IO::Socket::INET->new(PeerAddr => "www.google.com:80",
@@ -64,15 +78,6 @@
# XXX could try to send a GET to it???
close($s);

- print < -
-You appear to be directly connected to the Internet. I have some tests
-that tries to access some sites on the net to verify that the new HTTP/1.1
-support works as it should.
-
-EOT
-
- if (prompt("Do you want to enable these tests?", "y") =~ /^y/i) {
open(ENABLED, ">t/live/ENABLED") || die "Can't enable: $!";
close(ENABLED);

@@ -94,7 +99,12 @@
}
else {
unlink("t/live/ENABLED");
- }
+ print < +
+You dont appear to be directly connected to the Internet.
+I skip the tests that try to access Internet sites.
+
+EOT
}
}