libwww-perl / WWW-Mechanize

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

t-test error, can't create a temp file #350

Closed PhilterPaper closed 1 year ago

PhilterPaper commented 1 year ago

WWW::Mechanize 2.14 on Windows 10, Strawberry Perl 5.24, 5.26, and 5.32

...
t/local/submit.t ......................... ok
t/mech-dump/mech-dump.t .................. 1/?     # No tests run!

#   Failed test 'No tests run for subtest "Local file not found"'
#   at t/mech-dump/mech-dump.t line 171.
Error in tempfile() using template \XXXXXXXXXX: Could not create temp file \gNUiCGJnBU: Permission denied at C:/Strawberry/perl/site/lib/Capture/Tiny.pm line 360.
# Tests were run but no plan was declared and done_testing() was not seen.
# Looks like your test exited with 2 just after 2.
t/mech-dump/mech-dump.t .................. Dubious, test returned 2 (wstat 512, 0x200)
Failed 1/2 subtests
t/new.t .................................. ok
...

Possibly you're trying to create a temp file in root (\), which isn't permitted? I wouldn't be surprised if that also failed in Unixy systems.

simbabque commented 1 year ago

This is interesting, thank you @PhilterPaper. If you have a previous version installed, could you please see if the mech-dump utility works on that at for downloading something? Thanks a lot!

PhilterPaper commented 1 year ago

I have 2.13 installed (2.14 upgrade failed). What exactly do you want me to run, and get back to you with? I don't use WWW::Mechanize, but it was pre-installed in Strawberry Perl (Windows) and gives an annoying update failure that I'm reporting.

simbabque commented 1 year ago

I'm sorry about that. Let's see if we can figure this out so we can fix it.

I thought it might be something that was broken before, but wasn't covered by a test, and the changes to the test have now uncovered this. But looking at it more, I think that it is the test that causes it. I don't have access to a Windows 10 machine unfortunately, so I've contacted a friend to help me reproduce it.

Possibly you're trying to create a temp file in root (), which isn't permitted? I wouldn't be surprised if that also failed in Unixy systems.

This sounds like a good assumption. We'll start there. We use Capture::Tiny to get the output from mech-dump in the test. I don't know why that would try to create its temp file in the root directory.

How are you running the update? What command did you run, and as what user?

PhilterPaper commented 1 year ago

I'm using the "cpan" command (Strawberry Perl), getting a list of packages to upgrade, and doing an "upgrade WWW::Mechanize" command. I am the only user of this machine, so I'm running as the only defined user (more or less with 'root' powers -- yeah, potentially it's dangerous, but with care it's doable, and Windows makes it painful to set up multiple users with different privileges like you do in Linux).

If your friend can't help with a Windows 10 machine, I would be happy to receive an install package (.tar.gz) from you and manually install it via cpan. Let me know, or if there is anything else I could do to help diagnose this.

soerenkornetzki commented 1 year ago

Hi @simbabque , as you had requested, here is my log:

Call:

C:\Users\soeren\Documents>cpanm WWW::Mechanize
--> Working on WWW::Mechanize
Fetching http://www.cpan.org/authors/id/S/SI/SIMBABQUE/WWW-Mechanize-2.14.tar.gz ... OK
cpanm (App::cpanminus) 1.7044 on perl 5.032001 built for MSWin32-x64-multi-thread
Work directory is C:\Users\soeren/.cpanm/work/1660823103.33500
You have make C:\Strawberry\c\bin\gmake.exe
You have LWP 6.52
Falling back to Archive::Tar 2.38
Searching WWW::Mechanize () on cpanmetadb ...
--> Working on WWW::Mechanize
Fetching http://www.cpan.org/authors/id/S/SI/SIMBABQUE/WWW-Mechanize-2.14.tar.gz
-> OK
Unpacking WWW-Mechanize-2.14.tar.gz
Entering WWW-Mechanize-2.14
Checking configure dependencies from META.json
Checking if you have ExtUtils::MakeMaker 6.58 ... Yes (7.58)
Configuring WWW-Mechanize-2.14
Running Makefile.PL
Warning: prerequisite HTML::Form 6.08 not found. We have 6.07.
Warning: prerequisite Test::Memory::Cycle 1.06 not found.
Warning: prerequisite Test::Taint 1.08 not found.
Checking if your kit is complete...

Error output:

t/local/submit.t ......................... ok
    # No tests run!

#   Failed test 'No tests run for subtest "Local file not found"'
#   at t/mech-dump/mech-dump.t line 171.
Error in tempfile() using template \XXXXXXXXXX: Could not create temp file \BmrE8Dd7Lv: Permission denied at C:/Strawberry/perl/vendor/lib/Capture/Tiny.pm line 360.
# Tests were run but no plan was declared and done_testing() was not seen.
# Looks like your test exited with 2 just after 2.
t/mech-dump/mech-dump.t .................. 
Dubious, test returned 2 (wstat 512, 0x200)
Failed 1/2 subtests 
t/new.t .................................. ok

Characteristics of this binary (from libperl): Compile-time options: HAS_TIMES HAVE_INTERP_INTERN MULTIPLICITY PERLIO_LAYERS PERL_COPY_ON_WRITE PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS PERL_MALLOC_WRAP PERL_OP_PARENT PERL_PRESERVE_IVUV USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_LOCALE_TIME USE_PERLIO USE_PERL_ATOF Built under MSWin32 Compiled at Jan 24 2021 15:05:42 @INC: C:/Strawberry/perl/site/lib/MSWin32-x64-multi-thread C:/Strawberry/perl/site/lib C:/Strawberry/perl/vendor/lib C:/Strawberry/perl/lib

simbabque commented 1 year ago

I have found a discussion on perlmonks that hints at it being the taint mode that we use in that test. I am going to try to move this new subtest into its own file without taint mode.

simbabque commented 1 year ago

I've pushed a possible fix. @PhilterPaper if it is not too much trouble, I would appreciate if you could clone this repository, check out the branch simbabque/gh-350 and run the tests for mech-dump:

$ prove -lv t/mech-dump

I could also push a trial release to PAUSE if that's easier. I've asked @soerenkornetzki to give it a try as well.

PhilterPaper commented 1 year ago

I put a copy on my desktop and ran prove. Here is the summary:

Test Summary Report
-------------------
t\autocheck.t                          (Wstat: 512 (exited 2) Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
t\file_upload.t                        (Wstat: 65280 (exited 255) Tests: 7 Failed: 3)
  Failed tests:  3-5
  Non-zero exit status: 255
  Parse errors: No plan found in TAP output
t\form_with_fields.t                   (Wstat: 256 (exited 1) Tests: 39 Failed: 1)
  Failed test:  24
  Non-zero exit status: 1
Files=44, Tests=554, 102 wallclock secs ( 0.31 usr +  0.30 sys =  0.61 CPU)
Result: FAIL

Then I ran as you requested:

C:\Users\Phil\Desktop\WWW-Mechanize-simbabque-gh-350>prove -lv t\mech-dump
t\mech-dump\file_not_found.t ..
ok 1 - Errors when a local file is not found
1..1
ok
t\mech-dump\mech-dump.t .......
# Subtest: Success
    ok 1 - First line matches
    ok 2 - Still some expected
    ok 3 - Still some actual
    ok 4 - Rest of the lines match
    1..4
ok 1 - Success
1..1
ok
All tests successful.
Files=2, Tests=2,  3 wallclock secs ( 0.03 usr +  0.05 sys =  0.08 CPU)
Result: PASS

Is this what you needed? I didn't do anything to update my Perl repository (\Strawberry) -- was I running the previous version or the new one? I can install ( cpan . ) this version into \Strawberry and run again, if I was using the 2.13 version.

PhilterPaper commented 1 year ago

After sending off the previous update, I decided there was no harm in installing that image (using cpan .). It appears to have installed correctly, and all t-tests passed. cpan says that WWW::Mechanize is now at 2.15. It sounds like your fix may have worked. I also ran prove -lv t\mech-dump and it passed. Any other testing or information needed? I think you can just go ahead and push out 2.15.

simbabque commented 1 year ago

I put a copy on my desktop and ran prove. Here is the summary:

Test Summary Report
-------------------
t\autocheck.t                          (Wstat: 512 (exited 2) Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
t\file_upload.t                        (Wstat: 65280 (exited 255) Tests: 7 Failed: 3)
  Failed tests:  3-5
  Non-zero exit status: 255
  Parse errors: No plan found in TAP output
t\form_with_fields.t                   (Wstat: 256 (exited 1) Tests: 39 Failed: 1)
  Failed test:  24
  Non-zero exit status: 1
Files=44, Tests=554, 102 wallclock secs ( 0.31 usr +  0.30 sys =  0.61 CPU)
Result: FAIL

This is expected. Just running prove with no arguments will only run the tests in the t folder, and it will use the installed version. That's probably why those tests failed, as those are newer than the code it ran against. You have to have the -l flag to load the lib directory into PERL5LIB and use the code that's there. It also hasn't run the full test suite, as there are subdirectories in t that it missed.

But that's fine, we know all of those pass.

Then I ran as you requested:

C:\Users\Phil\Desktop\WWW-Mechanize-simbabque-gh-350>prove -lv t\mech-dump
t\mech-dump\file_not_found.t ..
ok 1 - Errors when a local file is not found
1..1
ok
t\mech-dump\mech-dump.t .......
# Subtest: Success
    ok 1 - First line matches
    ok 2 - Still some expected
    ok 3 - Still some actual
    ok 4 - Rest of the lines match
    1..4
ok 1 - Success
1..1
ok
All tests successful.
Files=2, Tests=2,  3 wallclock secs ( 0.03 usr +  0.05 sys =  0.08 CPU)
Result: PASS

Is this what you needed?

Yes! Thank you very much. That is all I needed. I'm going to release a new version now.

I didn't do anything to update my Perl repository (\Strawberry) -- was I running the previous version or the new one? I can install ( cpan . ) this version into \Strawberry and run again, if I was using the 2.13 version.

I'm not sure how you did the installation. I haven't used cpan in a long time, I always use cpanm. Technically what you got from the source is not 2.15 yet. It's not even a trial release. So it will be out of sync with what is going to be released.

Please reinstall Mechanize when 2.15 is out.

$ cpan -f -i WWW::Mechanize

Or if you prefer the cpan shell:

cpan[1]> force install WWW::Mechanize
PhilterPaper commented 1 year ago

OK, will do on the 2.15 re-install when it comes out, since you say that this is not the final 2.15 (perhaps it should have been 2.14_01 or similar?). The way I installed was to unpack the zip file from GitHub into a desktop directory, cd to the directory, and run cpan . from the command line. Thanks for fixing this promptly.

simbabque commented 1 year ago

I've just pushed 2.15. By the time your day starts, it should be there.

OK, will do on the 2.15 re-install when it comes out, since you say that this is not the final 2.15 (perhaps it should have been 2.14_01 or similar?).

This has to do with how we do releases for most of the modules in the libwww-perl space. We use Dist::Zilla to handle releases, and the versioning happens automatically. After every release, the version is bumped. So the codebase will now have 2.16 right after the 2.15 release. When you installed from code, you just had a snapshot of a branch (that wasn't merged to master yet), but it would still have had the bump to be the next version.

Anyway, thank you for reporting this and for helping us solve it!

PhilterPaper commented 1 year ago

Just for the benefit of anyone reading this, I was suggesting that they use 2.14_01 for an intermediate (test) version between 2.14 and 2.15, as it permits the "real" 2.15 to overwrite the 2.14_01 when it's released. A lot of distributions do that, but if their build/distribution tools don't easily permit it, that's life, I guess. Anyway, the official 2.15 cleanly (force) installed on 5.24, 5.26, and 5.32; so I'm happy. Thanks again!