"make test" without network access

"make test" without network access

am 05.01.2005 19:48:29 von Gabor

I am resending this in the hope that with the new
subject line it will be clearer what I'd like to achieve.
I hope you forgive me for the duplication.

While installing libwww-perl "make test" tries to connect to
google.com. If successful then it asks the user if he wants
to run the tests requiring Internet access.

IMHO there are two problems with this
1) In some environments accessing google.com is forbidden and
it might put someone in trouble if his script tries to do that.

2) In automatic installations (e.g. CPAN smoke) the default of
testing using Internet site can cause unnecessary error messages.

(1) might not be a frequent issue and might be less of a problem but
(2) seems to be unnecessary at all.

I learned about it as it happened to me a couple of days ago:
some of the live/jigsaw tests failed. Later on they succeeded.


So 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.

Set the default on the "Shall I run the Internet tests ?" to "no".

Please let me know what do you think.

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
}
}