dagolden / Path-Tiny

File path utility
41 stars 59 forks source link

Windows 11: Failed test 'lstat' at t\filesystem.t line 420 (lstat->size returns zero) #269

Open hakonhagland opened 1 year ago

hakonhagland commented 1 year ago

I am trying to install Path::Tiny on Windows 11 using a debug version of perl 5.37.6 using MinGW-w64 and gcc 11.3.0 from https://winlibs.com/ (using the MSVCRT runtime library), more information here: https://github.com/Perl/perl5/issues/20395.

When testing Path::Tiny including the fix in #268 for realpath, I get:

>perl Makefile.PL
Generating a gmake-style Makefile
Writing Makefile for Path::Tiny
Writing MYMETA.yml and MYMETA.json

>gmake
cp p.pl blib\lib\Path\p.pl
cp lib/Path/Tiny.pm blib\lib\Path\Tiny.pm

C:\Users\hakon\perl\github\Path-Tiny>gmake test
"C:\perl-debug\bin\perl.exe" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib\lib', 'blib\arch')" t/*.t
t/basename.t ...................... ok
t/basic.t ......................... ok
t/children.t ...................... ok
t/chmod.t ......................... ok
t/digest.t ........................ ok
t/exception.t ..................... ok
t/exports.t ....................... ok
t/filesystem.t .................... 37/?
#   Failed test 'lstat'
#   at t/filesystem.t line 420.
# Looks like you failed 1 test of 104.
t/filesystem.t .................... Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/104 subtests
t/has_same_bytes.t ................ ok
t/input_output.t .................. ok
t/input_output_no_PU_UU.t ......... ok
t/input_output_no_UU.t ............ ok
t/locking.t ....................... ok
[...]

More information about the failed test:

>perl -Ilib t\filesystem.t
ok 1 - Got a filename via tmpnam()

[...]

ok 80 - copy()
ok 81 - touch can chain
not ok 82 - lstat
#   Failed test 'lstat'
#   at t\filesystem.t line 420.
ok 83 - realpath resolves symlinks
ok 84 - remove symbolic link

[...]

The problem is most likely that lstat->size returns zero on windows, see https://github.com/Perl/perl5/issues/20476 for more information. A fix has been proposed here: https://github.com/Perl/perl5/pull/20500 but has currently not been merged into blead.

hakonhagland commented 1 year ago

Added a PR to fix this, see https://github.com/dagolden/Path-Tiny/pull/270