Subject: | Using hardcoded port in t/cookies.t test is problematic |
t/cookies.t uses HTTP::Server::Simple which by default uses the port
8080. Using a hardcoded tcp port in test scripts is problematic; there's
no guarantee that no other program is using this port. Especially port
8080 is quite popular for WWW test servers, so it's likely that it's not
available. To simulate this, start just netcat:
nc -l 8080
and then run the cookies.t test:
Show quoted text
> make test TEST_FILES="t/cookies.t" TEST_VERBOSE=1
PERL_DL_NONLAZY=1 /usr/perl5.8.8-MB030/bin/perl
"-MExtUtils::Command::MM" "-e" "test_harness(1, 'blib/lib',
'blib/arch')" t/cookies.t
t/cookies....
1..14
# Server now running on port 8080, pid 74589
bind to *:8080: Address already in use at t/cookies.t line 59
ok 1 - The object isa WWW::Mechanize
not ok 2 - First fetch works
not ok 3 - First cookie matches
not ok 4 - Right title
not ok 5 - Second fetch works
not ok 6 - Second cookie matches
not ok 7 - Right title
not ok 8 - Cookie did not change...
not ok 9 - ... but back to the first page title
not ok 10 - Cookie did not change...
not ok 11 - On the proper 3rd page
not ok 12 - Got the third cookie
not ok 13 - Title is correct
ok 14 - Signaled the child process
# Failed test 'First fetch works'
# at t/cookies.t line 69.
# got: '500'
# expected: '200'
# Failed test 'First cookie matches'
# at t/cookies.t line 73.
# got: undef
# expected: 'Cookie #1'
# Failed test 'Right title'
# at t/cookies.t line 74.
# got: undef
# expected: 'Home of Cookie #1'
Use of uninitialized value in numeric gt (>) at
/usr/perl5.8.8-MB030/lib/site_perl/5.8.8/HTTP/Cookies.pm line 106,
<DATA> line 16.
<... snipped ...>
# Looks like you failed 12 tests of 14.
Dubious, test returned 12 (wstat 3072, 0xc00)
Failed 12/14 subtests
Test Summary Report
-------------------
t/cookies (Wstat: 3072 Tests: 14 Failed: 12)
Failed tests: 2-13
Non-zero exit status: 12
Files=1, Tests=14, 180 wallclock secs ( 0.02 usr 0.01 sys + 0.17 cusr
0.02 csys = 0.23 CPU)
Result: FAIL
This problem can also happen if two different perl installations on the
same machine try to test and install the distribution at the same time.
Regards,
Slaven