Net::hostent fails make test if can't resolve localhost
authorDavid Cantrell <david@cantrell.org.uk>
Wed, 8 Apr 2009 12:49:14 +0000 (14:49 +0200)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Wed, 8 Apr 2009 12:49:14 +0000 (14:49 +0200)
This happens on boxes which otherwise work Just Fine and whose resolvers
work Just Fine if they don't have /etc/hosts. This patch fixes the test
file by making it skip if localhost can't be resolved and /etc/hosts
doesn't exist.

Message-ID: <20090330205715.GA29690@bytemark.barnyard.co.uk>

lib/Net/hostent.t

index 2616b56..421f19d 100644 (file)
@@ -33,6 +33,10 @@ sub DIE {
 use Socket;
 
 my $h = gethost('localhost');
+SKIP: {
+skip "Can't resolve localhost and you don't have /etc/hosts", 6
+    if (!defined($h) && !-e '/etc/hosts');
+
 ok(defined $h,  "gethost('localhost')") ||
   DIE("Can't continue without working gethost: $!");
 
@@ -89,3 +93,4 @@ SKIP: {
         print "# " . $h->name . " " . join (",", @{$h->aliases}) . "\n";
     }
 }
+}