Subject: | local/back test fails if hostname doesn't resolve |
In t/local/back this code is executed:
my $server404 = HTTP::Daemon->new or die;
my $server404url = $server404->url;
die 'Cannot fork' if (! defined (my $pid404 = fork()));
END {
local $?;
kill KILL => $pid404; # Extreme prejudice intended, because we do not
# want the global cleanup to be done twice.
}
if (! $pid404) { # Fake HTTP server code: a true 404-compliant server!
while ( my $c = $server404->accept() ) {
while ( $c->get_request() ) {
$c->send_response( new HTTP::Response(404) );
$c->close();
}
}
}
$mech->get($server404url);
is( $mech->status, 404 , '404 check');
If you print the $server404url, instead of it being
http://localhost:43210/ it is http://host.name.com:43210/ and this test
will fail if host.name.com does not resolve to the local box IP.
I'm not sure where the hostname is determined, but it should test
against localhost, not the box hostname. This will prevent DNS issues
from affecting tests.