Subject: | [PATCH] easy fix for t/local/back.t 404 test on machine with invalid hostname |
For several WWW::Mechanize releases, I've been getting HTTP 500 errors
on test 28 of t/local/back.t (1.22 worked, everything through 1.32
failed). I finally found the tuits to figure out why. I put a Dumper()
call after the failing test and saw this:
not ok 28 - 404 check
# Failed test '404 check'
# at t/local/back.t line 153.
# got: '500'
# expected: '404'
$VAR1 = bless( {
'content' => '500 Can\'t connect to islug:57045 (Bad
hostname \'islug\')
',
...
That is, my machine has an ad-hoc local hostname which is causing
problems. I applied the following simple patch and the test now passes
for me. It looks like a very similar solution has been applied in
t/local/referer-server.
% diff -u t/local/back.t{~,}
--- t/local/back.t~ 2007-10-30 11:45:32.000000000 -0500
+++ t/local/back.t 2007-11-05 23:57:21.000000000 -0600
@@ -127,7 +127,8 @@
is( scalar @{$mech->{page_stack}}, 0, 'Pre-404 check' );
my $server404 = HTTP::Daemon->new or die;
-my $server404url = $server404->url;
+my $server404url = new URI($server404->url);
+$server404url->host('localhost');
die 'Cannot fork' if (! defined (my $pid404 = fork()));
END {