libwww-perl / WWW-Mechanize

Handy web browsing in a Perl object
https://metacpan.org/pod/WWW::Mechanize
Other
68 stars 53 forks source link

Install failing on RHEL 7.6 #276

Closed ludz-lim closed 4 years ago

ludz-lim commented 5 years ago

I'm getting the following error message when installing WWW::Mechanize on a RHEL7 machine using cpanm

t/frames.t ............................... ok

   Failed test '... and it was recorded in the history'
 at t/history.t line 131.
      got: '3'
   expected: '2'
 Looks like you failed 1 test of 28.
t/history.t ..............................
oalders commented 5 years ago

Do you have something running on localhost:80?

With this diff:

diff --git a/t/history.t b/t/history.t
index ee877be..b9b09ef 100644
--- a/t/history.t
+++ b/t/history.t
@@ -133,6 +133,8 @@ BEGIN {
         $mech->history(0)->{req}->uri, qr/localhost/,
         "... and the correct request was saved"
     );
+    use DDP;
+    diag np $mech->history;
 }

I see:

Use of uninitialized value $n in numeric eq (==) at /Users/olafalders/Documents/github/WWW-Mechanize/lib/WWW/Mechanize.pm line 620.
# \ {
#     req   HTTP::Request  {
#         Parents       HTTP::Message
#         public methods (9) : accept_decodable, as_string, clone, dump, method, new, parse, uri, uri_canonical
#         private methods (0)
#         internals: {
#             _content   "",
#             _headers   HTTP::Headers,
#             _method    "POST",
#             _uri       URI::http
#         }
#     },
#     res   HTTP::Response  {
#         Parents       HTTP::Message
#         public methods (24) : as_string, base, clone, code, current_age, dump, error_as_HTML, filename, fresh_until, freshness_lifetime, is_client_error, is_error, is_fresh, is_info, is_redirect, is_server_error, is_success, message, new, parse, previous, redirects, request, status_line
#         private methods (0)
#         internals: {
#             _content   "Can't connect to localhost:80
#
# Connection refused at /Users/olafalders/.plenv/versions/5.26.1/lib/perl5/site_perl/5.26.1/LWP/Protocol/http.pm line 46.
# ",
#             _headers   HTTP::Headers,
#             _msg       "Can't connect to localhost:80",
#             _rc        500,
#             _request   var{req}
#         }
#     }
# }

So, it looks like the test just assumes that there's no web server running and that a failure will end up in the history. We should change that POST to a local file GET or something similar. Just wondering if that's what happening in your case.

ludz-lim commented 5 years ago

I have Apache running on that machine. I was able to install WWW:Mechanize after stopping apache.

genehack commented 4 years ago

FWIW, I'm currently being bitten by this same failing test. Current Debian, running Nginx on port 80.

Changing the t/history_2.html file so that the form target was http://localhost:6667 allowed the test to pass.