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

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

Closed
PhilterPaper opened this issue Aug 16, 2022 · 13 comments · Fixed by #353
Closed

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

PhilterPaper opened this issue Aug 16, 2022 · 13 comments · Fixed by #353

Comments

@PhilterPaper
Copy link

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
Copy link
Contributor

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
Copy link
Author

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
Copy link
Contributor

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
Copy link
Author

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
Copy link

soerenkornetzki commented Aug 18, 2022

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
  • This is perl 5, version 32, subversion 1 (v5.32.1) built for MSWin32-x64-multi-thread
  • cpanm (App::cpanminus) version 1.7044 (C:\Strawberry\perl\bin/cpanm)
  • C:\Strawberry\perl\bin/cpan version 1.64 calling Getopt::Std::getopts (version 1.12 [paranoid])
  • Win32 strawberry-perl 5.32.1.1 #1 Sun Jan 24 15:00:15 2021 x64
  • strawberry-perl-5.32.1.1-64bit.msi
  • Windows 10 Pro 21H2 OS Build 19044.1889
  • Bitdefender Total Security 26.0.23.80 (2022-08-09 08:11), TIU 9418767 E 7.92621 (2022-08-18 13:32)
  Platform:
    osname=MSWin32
    osvers=10.0.19042.746
    archname=MSWin32-x64-multi-thread
    uname='Win32 strawberry-perl 5.32.1.1 #1 Sun Jan 24 15:00:15 2021 x64'
    config_args='undef'
    hint=recommended
    useposix=true
    d_sigaction=undef
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=undef
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='gcc'
    ccflags =' -DWIN32 -DWIN64 -D__USE_MINGW_ANSI_STDIO -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -fwrapv -fno-strict-aliasing -mms-bitfields'
    optimize='-s -O2'
    cppflags='-DWIN32'
    ccversion=''
    gccversion='8.3.0'
    gccosandvers=''
    intsize=4
    longsize=4
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='long long'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='g++'
    ldflags ='-s -L"C:\STRAWB~1\perl\lib\CORE" -L"C:\STRAWB~1\c\lib"'
    libpth=C:\STRAWB~1\c\lib C:\STRAWB~1\c\x86_64-w64-mingw32\lib C:\STRAWB~1\c\lib\gcc\x86_64-w64-mingw32\8.3.0
    libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32
    libc=
    so=dll
    useshrplib=true
    libperl=libperl532.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs
    dlext=xs.dll
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags='-mdll -s -L"C:\STRAWB~1\perl\lib\CORE" -L"C:\STRAWB~1\c\lib"'


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
Copy link
Contributor

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 added a commit that referenced this issue Aug 19, 2022
It seems that on certain Windows versions File::Temp is not working
properly when run under taint mode. This problem must have been around
for a while. Test::Output uses File::Temp, and therefore runs into this
problem as our mech-dump.t has had the -T flag enabled. I do not know
why we run under taint for some tests, but I have decided the most
pragmatic fix is to undo my previous changes from #292 to the test an to
move this particular test into its own file, which can run without
taint.

Also see https://www.perlmonks.org/?node_id=1122816 for details on the
original problem.
@simbabque
Copy link
Contributor

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
Copy link
Author

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
Copy link
Author

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
Copy link
Contributor

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
Copy link
Author

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.

oalders pushed a commit that referenced this issue Aug 20, 2022
It seems that on certain Windows versions File::Temp is not working
properly when run under taint mode. This problem must have been around
for a while. Test::Output uses File::Temp, and therefore runs into this
problem as our mech-dump.t has had the -T flag enabled. I do not know
why we run under taint for some tests, but I have decided the most
pragmatic fix is to undo my previous changes from #292 to the test an to
move this particular test into its own file, which can run without
taint.

Also see https://www.perlmonks.org/?node_id=1122816 for details on the
original problem.
@simbabque
Copy link
Contributor

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
Copy link
Author

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!

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