Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows-only failure with base/ua.t #357

Closed
PhilterPaper opened this issue Dec 20, 2020 · 13 comments · Fixed by #358
Closed

Windows-only failure with base/ua.t #357

PhilterPaper opened this issue Dec 20, 2020 · 13 comments · Fixed by #358

Comments

@PhilterPaper
Copy link

PhilterPaper commented Dec 20, 2020

Windows 10, Strawberry Perl 5.26.1

Recent release(s) of LWP have been failing (MSWIN32) on lines 174 and 175 of t/base/ua.t. I haven't been able to fix it, but I do note that both the domains you use: example.com and otherexample.com, are real, existing domains! The second one is NSFW (porn), by the way. Changing example to exampleX everywhere (and likewise for otherexample) didn't fix it, so that may not be the problem.

The second problem is that it gets an undef instead of "Environment contains multiple differing definitions...". Is @warn set somewhere?

C:\Users\Phil\Desktop\libwww-perl-6.50\t\base>perl ua.t
# Subtest: proxy settings from the constructor
    1..4
    ok 1 - $ua->proxy("ftp")
    ok 2 - $ua->proxy("http)
    ok 3 - $ua->proxy("https)
    ok 4 - no_proxy set to ['test.com']
ok 1 - proxy settings from the constructor
ok 2 - $ua->agent
ok 3 - $ua->proxy(ftp => "http://www.sol.no")
ok 4 - $ua->proxy("ftp")
ok 5 - $ua->proxy([qw(ftp http wais)], "http://proxy.foo.com")
ok 6 - $ua->proxy("http")
ok 7 - ref($ua->default_headers)
ok 8 - $ua->default_headers->header("Foo")
ok 9 - $ua->default_header("Foo")
ok 10 - simple_request: Method Missing: invalid request
ok 11 - simple_request: Invalid Protocol: invalid request
ok 12 - simple_request: Invalid Scheme: invalid request
ok 13 - Full $ua->get->content
ok 14 - POST http://www.example.com
# User-Agent: foo/0.1
# Content-Length: 8
# Content-Type: application/x-www-form-urlencoded
# Foo: bar
# Multi: 1
# Multi: 2
#
# x=y&f=ff
#
ok 15 - PUT http://www.example.com
# User-Agent: foo/0.1
# Content-Length: 8
# Content-Type: application/x-www-form-urlencoded
# Foo: bar
# Multi: 1
# Multi: 2
#
# x=y&f=ff
#
ok 16 - PATCH http://www.example.com
# User-Agent: foo/0.1
# Content-Length: 8
# Content-Type: application/x-www-form-urlencoded
# Foo: bar
# Multi: 1
# Multi: 2
# x=y&f=ff
#
ok 17 - ref($clone->{proxy})
ok 18 - $ua->proxy(http => undef)
ok 19 - $ua->proxy('http')
ok 20 - $res->header("Content-Style-Type", "text/css")
ok 21 - $res->header("Content-Script-Type", "text/javascript")
ok 22 - $ua->ssl_opts
ok 23 - $ua->ssl_opts("verify_hostname")
ok 24 - $ua->ssl_opts("verify_hostname" => 0)
ok 25 - $ua->ssl_opts("verify_hostname")
ok 26 - $ua->ssl_opts("verify_hostname" => undef)
ok 27 - $ua->ssl_opts("verify_hostname")
ok 28 - $ua->ssl_opts
ok 29 - $ua->ssl_opts("verify_hostname")
ok 30 - $ua->ssl_opts("verify_hostname")
ok 31 - $ua->ssl_opts("verify_hostname")
ok 32 - $ua->ssl_opts("SSL_ca_file")
ok 33 - $ua->ssl_opts("verify_hostname")
ok 34 - $ua->ssl_opts("verify_hostname")
ok 35 - $ua->ssl_opts("verify_hostname")
ok 36 - $ua->ssl_opts("verify_hostname")
ok 37 - $ua->ssl_opts("verify_hostname")
ok 38 - $ua->ssl_opts("verify_hostname")
ok 39
not ok 40 - proxy('http') returns URL
#   Failed test 'proxy('http') returns URL'
#   at ua.t line 174.
#          got: 'http://otherexample.com'
#     expected: 'http://example.com'
not ok 41
#   Failed test at ua.t line 175.
#          got: undef
#     expected: 'Environment contains multiple differing definitions for 'http_proxy'.
# Using value from 'HTTP_PROXY' (http://example.com) and ignoring 'http_proxy' (http://otherexample.com)'
ok 42 - proxy('http') returns undef
ok 43 - proxy('http') returns URL
ok 44 - proxy('http') returns undef
ok 45 - proxy('http') returns URL
ok 46 - $ua->proxy('http')
ok 47 - $ua->proxy('http')
ok 48 - $ua->conn_cache
ok 49 - $ua->conn_cache
ok 50 - $ua->conn_cache
ok 51 - $ua->conn_cache->total_capacity
1..51
# Looks like you failed 2 tests of 51.

No idea why these tests are supposedly working on non-Windows platforms, but not on Windows.

BTW, if you have no Windows to test on, I would be happy to have you send me a libwww-perl-VER.tar.gz file to test install and report back the messages.

@oalders
Copy link
Member

oalders commented Dec 21, 2020

It sounds like this change is behind this: #355

Do you have HTTP_PROXY and http_proxy set in your env?

@PhilterPaper
Copy link
Author

According to the Windows "Environment Variables" display/edit dialog, there's nothing by either name.

@oalders
Copy link
Member

oalders commented Dec 21, 2020

Right, sorry. Those vars are being set in the test. https://metacpan.org/source/OALDERS/libwww-perl-6.50/t%2Fbase%2Fua.t#L165-188

@oalders
Copy link
Member

oalders commented Dec 23, 2020

@oalders
Copy link
Member

oalders commented Dec 23, 2020

Are env vars on Windows case insensitive?

@genio
Copy link
Member

genio commented Dec 23, 2020

PS C:\Users\cwhitener> $env:Foo='bar'
PS C:\Users\cwhitener> echo $env:Foo
bar
PS C:\Users\cwhitener> echo $env:FOO
bar
PS C:\Users\cwhitener> perl -E 'say $ENV{FOO}'
bar
PS C:\Users\cwhitener> perl -E 'say $ENV{Foo}'
bar
PS C:\Users\cwhitener>

@genio
Copy link
Member

genio commented Dec 23, 2020

PS C:\Users\cwhitener> cpanm --test-only -v LWP
cpanm (App::cpanminus) 1.7044 on perl 5.030000 built for MSWin32-x64-multi-thread
Work directory is C:\Users\CWHITE~2\_psperl\_perls\PERL64~1.1\data/.cpanm/work/1608742776.12684
You have make C:\Users\cwhitener\_psperl\_perls\perl64-5.30.0.1\c\bin\gmake.exe
You have LWP 6.39
Falling back to Archive::Tar 2.32
Searching LWP () on cpanmetadb ...
--> Working on LWP
Fetching http://www.cpan.org/authors/id/O/OA/OALDERS/libwww-perl-6.50.tar.gz ... OK
Unpacking libwww-perl-6.50.tar.gz
Entering libwww-perl-6.50
Checking configure dependencies from META.json
Checking if you have File::Copy 0 ... Yes (2.34)
Checking if you have CPAN::Meta::Requirements 2.120620 ... Yes (2.140)
Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (7.36)
Checking if you have Getopt::Long 0 ... Yes (2.5)
Checking if you have Module::Metadata 0 ... Yes (1.000036)
Running Makefile.PL
Configuring libwww-perl-6.50 ... HTTP::Status already exists in PREREQ_PM (at version 6.07) -- need to do a sane metamerge! at Makefile.PL line 159.
HTTP::Status already exists in FallbackPrereqs (at version 6.07) -- need to do a sane metamerge! at Makefile.PL line 162.
Checking if your kit is complete...
Looks good
Generating a gmake-style Makefile
Writing Makefile for libwww::perl
Writing MYMETA.yml and MYMETA.json
OK
Checking dependencies from MYMETA.json ...
Checking if you have Try::Tiny 0 ... Yes (0.30)
Checking if you have MIME::Base64 2.1 ... Yes (3.15)
Checking if you have IO::Socket 0 ... Yes (1.40)
Checking if you have FindBin 0 ... Yes (1.51)
Checking if you have Net::FTP 2.58 ... Yes (3.11)
Checking if you have HTTP::Daemon 6 ... Yes (6.04)
Checking if you have Encode::Locale 0 ... Yes (1.05)
Checking if you have LWP::MediaTypes 6 ... Yes (6.04)
Checking if you have HTML::Entities 0 ... Yes (3.69)
Checking if you have strict 0 ... Yes (1.11)
Checking if you have File::Spec 0 ... Yes (3.78)
Checking if you have HTTP::Cookies 6 ... Yes (6.04)
Checking if you have HTTP::Request::Common 6 ... Yes (6.18)
Checking if you have Net::HTTP 6.18 ... Yes (6.19)
Checking if you have HTTP::Date 6 ... Yes (6.02)
Checking if you have Test::RequiresInternet 0 ... Yes (0.05)
Checking if you have URI 1.10 ... Yes (1.76)
Checking if you have Encode 2.12 ... Yes (3.01)
Checking if you have warnings 0 ... Yes (1.44)
Checking if you have ExtUtils::MakeMaker 0 ... Yes (7.36)
Checking if you have HTML::HeadParser 0 ... Yes (3.71)
Checking if you have base 0 ... Yes (2.27)
Checking if you have Scalar::Util 0 ... Yes (1.50)
Checking if you have Test::Needs 0 ... Yes (0.002006)
Checking if you have File::Listing 6 ... Yes (6.04)
Checking if you have Test::More 0 ... Yes (1.302175)
Checking if you have IO::Select 0 ... Yes (1.40)
Checking if you have Digest::MD5 0 ... Yes (2.55)
Checking if you have HTTP::Request 6 ... Yes (6.18)
Checking if you have WWW::RobotRules 6 ... Yes (6.02)
Checking if you have Test::Fatal 0 ... Yes (0.014)
Checking if you have HTTP::Negotiate 6 ... Yes (6.01)
Checking if you have HTTP::Response 6 ... Yes (6.18)
Checking if you have HTTP::Status 6.18 ... Yes (6.18)
Checking if you have URI::Escape 0 ... Yes (3.31)
Building and testing libwww-perl-6.50 ... cp lib/LWP/Protocol/data.pm blib\lib\LWP\Protocol\data.pm
cp lib/LWP/Debug/TraceHTTP.pm blib\lib\LWP\Debug\TraceHTTP.pm
cp lib/LWP/Protocol/loopback.pm blib\lib\LWP\Protocol\loopback.pm
cp lib/LWP/UserAgent.pm blib\lib\LWP\UserAgent.pm
cp lib/LWP/Protocol/nntp.pm blib\lib\LWP\Protocol\nntp.pm
cp lib/LWP/Protocol/ftp.pm blib\lib\LWP\Protocol\ftp.pm
cp lib/LWP/Protocol/cpan.pm blib\lib\LWP\Protocol\cpan.pm
cp lib/LWP/Protocol/mailto.pm blib\lib\LWP\Protocol\mailto.pm
cp lib/LWP.pm blib\lib\LWP.pm
cp lib/LWP/ConnCache.pm blib\lib\LWP\ConnCache.pm
cp lib/LWP/RobotUA.pm blib\lib\LWP\RobotUA.pm
cp lib/LWP/Protocol.pm blib\lib\LWP\Protocol.pm
cp lib/LWP/Protocol/nogo.pm blib\lib\LWP\Protocol\nogo.pm
cp lib/LWP/MemberMixin.pm blib\lib\LWP\MemberMixin.pm
cp lib/LWP/Simple.pm blib\lib\LWP\Simple.pm
cp lib/LWP/Authen/Digest.pm blib\lib\LWP\Authen\Digest.pm
cp lib/LWP/Protocol/file.pm blib\lib\LWP\Protocol\file.pm
cp lib/LWP/Debug.pm blib\lib\LWP\Debug.pm
cp lib/LWP/Protocol/http.pm blib\lib\LWP\Protocol\http.pm
cp lib/LWP/Authen/Ntlm.pm blib\lib\LWP\Authen\Ntlm.pm
cp lib/LWP/Authen/Basic.pm blib\lib\LWP\Authen\Basic.pm
cp lwpcook.pod blib\lib\libwww\lwpcook.pod
cp lib/LWP/Protocol/gopher.pm blib\lib\LWP\Protocol\gopher.pm
cp lib/LWP/DebugFile.pm blib\lib\LWP\DebugFile.pm
cp lwptut.pod blib\lib\libwww\lwptut.pod
"C:\Users\cwhitener\_psperl\_perls\perl64-5.30.0.1\perl\bin\perl.exe" -MExtUtils::Command -e cp -- bin/lwp-download blib\script\lwp-download
pl2bat.bat blib\script\lwp-download
"C:\Users\cwhitener\_psperl\_perls\perl64-5.30.0.1\perl\bin\perl.exe" -MExtUtils::Command -e cp -- bin/lwp-dump blib\script\lwp-dump
pl2bat.bat blib\script\lwp-dump
"C:\Users\cwhitener\_psperl\_perls\perl64-5.30.0.1\perl\bin\perl.exe" -MExtUtils::Command -e cp -- bin/lwp-mirror blib\script\lwp-mirror
pl2bat.bat blib\script\lwp-mirror
"C:\Users\cwhitener\_psperl\_perls\perl64-5.30.0.1\perl\bin\perl.exe" -MExtUtils::Command -e cp -- bin/lwp-request blib\script\lwp-request
pl2bat.bat blib\script\lwp-request
"C:\Users\cwhitener\_psperl\_perls\perl64-5.30.0.1\perl\bin\perl.exe" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib\lib', 'blib\arch')" t/*.t t/base/*.t t/base/protocols/*.t t/leak/*.t t/local/*.t t/robot/*.t
t/00-report-prereqs.t .......... #
# Versions for all modules listed in MYMETA.json (including optional ones):
#
# === Configure Requires ===
#
#     Module                       Want     Have
#     ------------------------ -------- --------
#     CPAN::Meta::Requirements 2.120620    2.140
#     ExtUtils::MakeMaker           any     7.36
#     File::Copy                    any     2.34
#     Getopt::Long                  any      2.5
#     Module::Metadata              any 1.000036
#
# === Build Requires ===
#
#     Module              Want Have
#     ------------------- ---- ----
#     ExtUtils::MakeMaker  any 7.36
#
# === Test Requires ===
#
#     Module                 Want     Have
#     ---------------------- ---- --------
#     ExtUtils::MakeMaker     any     7.36
#     File::Spec              any     3.78
#     FindBin                 any     1.51
#     Test::Fatal             any    0.014
#     Test::More              any 1.302175
#     Test::Needs             any 0.002006
#     Test::RequiresInternet  any     0.05
#
# === Test Recommends ===
#
#     Module              Want     Have
#     --------------- -------- --------
#     CPAN::Meta      2.120900 2.150010
#     Test::LeakTrace      any     0.16
#
# === Runtime Requires ===
#
#     Module                Want Have
#     --------------------- ---- ----
#     Digest::MD5            any 2.55
#     Encode                2.12 3.01
#     Encode::Locale         any 1.05
#     File::Listing            6 6.04
#     HTML::Entities         any 3.69
#     HTML::HeadParser       any 3.71
#     HTTP::Cookies            6 6.04
#     HTTP::Daemon             6 6.04
#     HTTP::Date               6 6.02
#     HTTP::Negotiate          6 6.01
#     HTTP::Request            6 6.18
#     HTTP::Request::Common    6 6.18
#     HTTP::Response           6 6.18
#     HTTP::Status          6.18 6.18
#     IO::Select             any 1.40
#     IO::Socket             any 1.40
#     LWP::MediaTypes          6 6.04
#     MIME::Base64           2.1 3.15
#     Net::FTP              2.58 3.11
#     Net::HTTP             6.18 6.19
#     Scalar::Util           any 1.50
#     Try::Tiny              any 0.30
#     URI                   1.10 1.76
#     URI::Escape            any 3.31
#     WWW::RobotRules          6 6.02
#     base                   any 2.27
#     strict                 any 1.11
#     warnings               any 1.44
#
# === Runtime Suggests ===
#
#     Module               Want Have
#     -------------------- ---- ----
#     Authen::NTLM         1.02 1.09
#     Data::Dump           1.13 1.23
#     IO::Socket::INET      any 1.40
#     LWP::Protocol::https 6.02 6.07
#
t/00-report-prereqs.t .......... ok
t/10-attrs.t ................... ok
t/base/default_content_type.t .. # Some tests for the PUT/PATCH methods can only be run on
# HTTP::Request version 6.07/6.12 or higher.
# If your version isn't good enough, we'll skip those.
# Your version is 6.18 and that's good enough
t/base/default_content_type.t .. ok
t/base/protocols.t ............. ok
t/base/protocols/nntp.t ........ skipped: nntp.perl.org is unstable and Test::RequiresInternet is not catching it
t/base/proxy.t ................. ok
t/base/simple.t ................ ok
t/base/ua.t .................... 40/?
#   Failed test 'proxy('http') returns URL'
#   at t/base/ua.t line 174.
#          got: 'http://otherexample.com'
#     expected: 'http://example.com'

#   Failed test at t/base/ua.t line 175.
#          got: undef
#     expected: 'Environment contains multiple differing definitions for 'http_proxy'.
# Using value from 'HTTP_PROXY' (http://example.com) and ignoring 'http_proxy' (http://otherexample.com)'
# Looks like you failed 2 tests of 51.
t/base/ua.t .................... Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/51 subtests
t/base/ua_handlers.t ........... ok
t/leak/no_leak.t ............... ok
t/local/autoload-get.t ......... ok
t/local/autoload.t ............. ok
t/local/get.t .................. ok
t/local/http.t ................. ok
t/local/httpsub.t .............. ok
t/local/protosub.t ............. ok
t/redirect.t ................... ok
t/robot/ua-get.t ............... ok
t/robot/ua.t ................... ok

Test Summary Report
-------------------
t/base/ua.t                  (Wstat: 512 Tests: 51 Failed: 2)
  Failed tests:  40-41
  Non-zero exit status: 2
Files=19, Tests=270, 32 wallclock secs ( 0.08 usr +  0.14 sys =  0.22 CPU)
Result: FAIL
Failed 1/19 test programs. 2/270 subtests failed.
gmake: *** [Makefile:987: test_dynamic] Error 255
FAIL
! Testing LWP failed. See C:\Users\CWHITE~2\_psperl\_perls\PERL64~1.1\data\.cpanm\work\1608742776.12684\build.log for details. Retry with --force to force install it.
Expiring 2 work directories.
PS C:\Users\cwhitener>

@oalders
Copy link
Member

oalders commented Dec 23, 2020

Thanks @genio! I guess we can just skip that particular test on Windows?

@PhilterPaper
Copy link
Author

So on Windows, ENV{HTTP_PROXY} and ENV{http_proxy} are the same. I just tried setting FOO=BAR (worked), and then foo=bar (replaced FOO).

Skipping the test on Windows would be appropriate, if it's important that the same name (different case) be used for these tests. Feel free to close this ticket once you've decided what to do.

@genio
Copy link
Member

genio commented Dec 23, 2020

@oalders Skipping it sounds like the quick/simple solution to get a fix out to me.

@oalders
Copy link
Member

oalders commented Dec 23, 2020

Thanks @PhilterPaper and @genio. I'll get a new release out that skips that test. As I was looking into this I realized that most of the tests weren't actually being run in CI for Windows, so I'll fix that at the same time to ensure the tests are actually passing.

oalders added a commit that referenced this issue Dec 23, 2020
oalders added a commit that referenced this issue Dec 23, 2020
oalders added a commit that referenced this issue Dec 29, 2020
@PhilterPaper
Copy link
Author

LWP 6.51 (as well as LWP::Protocol::https 6.10) now installs cleanly on Windows. Thank you!

@oalders
Copy link
Member

oalders commented Jan 1, 2021

Thanks for the follow-up, @PhilterPaper. I appreciate your help with this. Happy New Year!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants