drmuey / p5-file-copy-recursive Goto Github PK
View Code? Open in Web Editor NEWPerl extension for recursively copying files and directories
Perl extension for recursively copying files and directories
# Testing legacy File::Copy::Recursive::pathmk() 0.45
Can't locate object method "visit" via package "Path::Tiny" at t/05.legacy-pathmk_unc.t line 55.
# Looks like you planned 6 tests but ran 2.
# Looks like your test exited with 2 just after 2.
t/05.legacy-pathmk_unc.t ..
Dubious, test returned 2 (wstat 512, 0x200)
As 05.legacy-pathmk_unc.t is active only on Windows, problem does not manifest on other OSes.
Path::Tiny->visit was introduced in version 0.065, I suggest just skipping test with older versions.
Testing if symlink is supported by perl does not mean it is supported in the current session, at least on MSWin32. C.f. briandfoy/test-file#36 for a similar discussion.
Once Test::File would be fixed, I guess it could be used if it export its method to check for symlink availability.
This test program (basically just the dircopy) exhibits different behavior on 0.38 vs. 0.39. on 0.38, foo_dst, foo_dst/a, and foo_dst/a/b is created and populated with bar.txt.
On 0.39, ./foo_dst isn't created at all.
#!/usr/bin/perl
# Sample code - foo_dst will not exist using 0.39.
use strict;
use warnings;
use File::Copy::Recursive qw(fcopy rcopy dircopy);
MAIN: {
mkdir "foo_src";
open my $fh, ">", "foo_src/bar.txt"; close $fh;
my $src = "./foo_src";
my $dst = "./foo_dst/a/b";
dircopy($src, $dst);
}
At some point, a File::Spec::splitdir and File::Spec::catdir was changed to a File::Spec::splitpath and File::Spec::splitdir. I.E. I can get this to pass tests by simply changing:
lib/File/Copy/Recursive.pm
...
sub pathmk {
my @parts = File::Spec->splitpath( shift() );
my $nofatal = shift;
my $pth = $parts[0];
my $zer = 0;
if ( !$pth ) {
$pth = File::Spec->catpath( $parts[0], $parts[1], '' );
$zer = 1;
}
if ( !$pth ) {
$pth = File::Spec->catpath( $parts[0], $parts[1], $parts[2] );
$zer = 2;
}
...
to:
sub pathmk {
my @parts = File::Spec->splitdir( shift() );
my $nofatal = shift;
my $pth = $parts[0];
my $zer = 0;
if ( !$pth ) {
$pth = File::Spec->catdir( $parts[0], $parts[1], '' );
$zer = 1;
}
if ( !$pth ) {
$pth = File::Spec->catdir( $parts[0], $parts[1], $parts[2] );
$zer = 2;
}
...
Note the change from splitpath to splitdir and the change from catpath to catdir (x2).
I doubt that is the proper fix - I didn't spend a lot of time trying to figure out what the proper fix is, but I hope this can help you, and I'm thinking this is a bug in File::Copy::Recursive.
This is keeping installs of Dist::Zilla from installing (unless tests are disabled) if version 0.39 of F::C::R is installed.
I hope this gives you enough to go on to get this fixed. If you think it's actually a Dist::Zilla issue, just comment and I'll ping them over there.
Thanks,
-- Joelle Maslak
File::Copy::Recursive, and anything that depends on it, won't build on a fresh install of some old versions of perl, because the EU::MM bundled with them doesn't understand TEST_REQUIRES and so the dependencies on things like Test::File and Test::Warnings won't be spotted. In particular this affects Test::File::ShareDir, which affects DateTime::Locale, which affects DateTime, which affects, well, just about everything.
The fix is to either merge TEST_REQUIRES into PREREQ_PM or, I think, declare the requirement for a modern EU::MM in META.json.
To see this bug in action, search for Unpacking File-Copy-Recursive-0.45.tar.gz
here and watch as it fails to build
In my shell configuration, I set a UMASK. Installing the module locally, tests complain about the file mode (see reports below). Reinstalling with umask 022
, there is no error. In my opinion, it would be better for testing to set UMASK explicitly, so that users can freely chose their UMASK.
(Perl 5.6.21, x86_64-linux-thread-multi, File-Copy-Recursive-0.40
).
PERL_DL_NONLAZY=1 "/home/…/perl5/perlbrew/perls/perl-5.26.1/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00.load.t ............... ok
t/01.legacy.t ............. 37/? # File [/tmp/u90MagnmCM/what/what] mode is not 0751!
# Failed test 'DirPerms in pathmk() effects initial new dir'
# at t/01.legacy.t line 208.
# File [/tmp/u90MagnmCM/what/what/what] mode is not 0751!
# Failed test 'DirPerms in pathmk() effects subsequent new dir'
# at t/01.legacy.t line 209.
# File [/tmp/u90MagnmCM/new] mode is not 0751!
# Failed test 'DirPerms in dircopy() effects dir (new)'
# at t/01.legacy.t line 215.
# File [/tmp/u90MagnmCM/new/foo] mode is not 0751!
# Failed test 'DirPerms in dircopy() effects dir (new/foo)'
# at t/01.legacy.t line 215.
# File [/tmp/u90MagnmCM/new/foo/bar] mode is not 0751!
# Failed test 'DirPerms in dircopy() effects dir (new/foo/bar)'
# at t/01.legacy.t line 215.
# File [/tmp/u90MagnmCM/new/foo/baz] mode is not 0751!
# Failed test 'DirPerms in dircopy() effects dir (new/foo/baz)'
# at t/01.legacy.t line 215.
# File [/tmp/u90MagnmCM/new/foo/bar/wop] mode is not 0751!
# Failed test 'DirPerms in dircopy() effects dir (new/foo/bar/wop)'
# at t/01.legacy.t line 215.
# Looks like you failed 7 tests of 109.
t/01.legacy.t ............. Dubious, test returned 7 (wstat 1792, 0x700)
Failed 7/109 subtests
t/02.legacy-symtogsafe.t .. ok
t/03.github-issue-5.t ..... ok
t/04.readonly-dir.t ....... ok
The repo now has t/02* files to make it easier to implement tests for each function. pull requests über welcome!
v0.40
e.g. http://www.cpantesters.org/cpan/report/8ec2ac32-6cd6-1014-bc8e-2e64d18befd2
# Failed test 'dircopy() defaults as expected when target does not exist'
# at t/01.legacy.t line 331.
# Structures begin differing at:
# $got->{C:/DOCUME~1/a/LOCALS~1/Temp/Oi0y_2kwjO/orig/empty} = Does not exist
# $expected->{C:/DOCUME~1/a/LOCALS~1/Temp/Oi0y_2kwjO/orig/empty} = 'file'
Error open (<) on 'C:/DOCUME~1/a/LOCALS~1/Temp/Oi0y_2kwjO/new/C:/DOCUME~1/a/LOCALS~1/Temp/Oi0y_2kwjO/new/data': Invalid argument at t/01.legacy.t line 338.
Branch modern_interface
MUST Ensure existing callers do not break. e.g. lazy load and goto & via AUTOLOAD
These appear to all be the same failure:
http://www.cpantesters.org/cpan/report/c4dbeeae-47fe-11e8-a1cf-bb670eaac09d
http://www.cpantesters.org/cpan/report/a8bb691e-47d3-11e8-a1cf-bb670eaac09d
http://www.cpantesters.org/cpan/report/0b13995e-4821-11e8-a1cf-bb670eaac09d
http://www.cpantesters.org/cpan/report/8c1da3ca-4810-11e8-a1cf-bb670eaac09d
http://www.cpantesters.org/cpan/report/cea13fec-47e6-11e8-a1cf-bb670eaac09d
initial hunch is removal is failing for some reason and cascades down to the rest of the tests
please, fix tests or add File::Find::Rule as dependency.
System: Windows 10, MSYS2, perl version 5.32.0.
$ make test
PERL_DL_NONLAZY=1 "/usr/bin/perl.exe" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00.load.t ............... ok
t/01.legacy.t ............. 4/?
# Failed test 'rcopy_glob() calls rcopy for each file in the glob'
# at t/01.legacy.t line 184.
# got: '3'
# expected: '4'
# Failed test 'rmove_glob() calls rmove for each file in the glob'
# at t/01.legacy.t line 193.
# got: '3'
# expected: '4'
t/01.legacy.t ............. 100/? # Looks like you failed 2 tests of 108.
t/01.legacy.t ............. Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/108 subtests
(less 8 skipped subtests: 98 okay)
t/02.legacy-symtogsafe.t .. ok
t/03.github-issue-5.t ..... ok
t/04.readonly-dir.t ....... ok
t/05.legacy-pathmk_unc.t .. skipped: Test irrelevant on non-windows OSs
Test Summary Report
-------------------
t/01.legacy.t (Wstat: 512 Tests: 108 Failed: 2)
Failed tests: 60-61
Non-zero exit status: 2
Files=6, Tests=150, 12 wallclock secs ( 0.12 usr 0.06 sys + 1.54 cusr 3.20 csys = 4.92 CPU)
Result: FAIL
Failed 1/6 test programs. 2/150 subtests failed.
make: *** [Makefile:881: test_dynamic] Error 255
In file Recursive.pm at p5-File-Copy-Recursive.
I always use taint mode and now I'm getting: "Insecure dependency in chdir while running with -T switch at /usr/local/libdata/perl5/site_perl/File/Copy/Recursive.pm line 414."
Seems the variable $starting_point isn't sanitized.
Is there an overwrite flag eg $skip == 0 do not overwrite existing or $skip ==1 overwrite all?
dircopy($source,$destination,$skip);
Also is there anything I can hook into to get current file/dir being processed?
Thanks vm it works a treat.
failures due to mv: rename /tmp/…/ to /tmp/…/: Not a directory
(trailing / in second arg?)
http://www.cpantesters.org/cpan/report/60a04192-53ca-11e8-9da6-f703c768dc7a
Checking if you have Test::Fatal 0 ... Yes (0.014)
Checking if you have Path::Tiny 0 ... Yes (0.104)
Building and testing File-Copy-Recursive-0.43 ... cp lib/File/Copy/Recursive.pm blib\lib\File\Copy\Recursive.pm
"D:\devel\perl32\perl\bin\perl.exe" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib\lib', 'blib\arch')" t/*.t
t/00.load.t ............... ok
t/01.legacy.t ............. ok
t/02.legacy-symtogsafe.t .. skipped: symlink tests not applicable on systems w/ out symlink support (MSWin32)
t/03.github-issue-5.t ..... ok
t/04.readonly-dir.t ....... skipped: test uses chmod which may or may not do what we want here, patches welcome!
t/05.legacy-pathmk_unc.t .. # Testing legacy File::Copy::Recursive::pathmk() 0.43
t/05.legacy-pathmk_unc.t .. 1/?
# Failed test 'pathmk regular path'
# at t/05.legacy-pathmk_unc.t line 60.
# Comparing $data as a Bag
# Missing: 'C:\Users\zdm\AppData\Local\Temp\XuNix3n9Lx/foo', 'C:\Users\zdm\AppData\Local\Temp\XuNix3n9Lx/foo/bar', 'C:\Users\zdm\AppData\Local\Temp\XuNix3n9Lx/foo/bar/baz'
# Extra: 'C:/Users/zdm/AppData/Local/Temp/XuNix3n9Lx/foo', 'C:/Users/zdm/AppData/Local/Temp/XuNix3n9Lx/foo/bar', 'C:/Users/zdm/AppData/Local/Temp/XuNix3n9Lx/foo/bar/baz'
# Failed test 'pathmk unc'
# at t/05.legacy-pathmk_unc.t line 78.
# Structures begin differing at:
# $got->[0] = 'C:/Users/zdm/AppData/Local/Temp/XuNix3n9Lx/foo'
# $expected->[0] = 'C:\Users\zdm\AppData\Local\Temp\XuNix3n9Lx'
# Looks like you failed 2 tests of 6.
t/05.legacy-pathmk_unc.t .. Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/6 subtests
Test Summary Report
-------------------
t/05.legacy-pathmk_unc.t (Wstat: 512 Tests: 6 Failed: 2)
Failed tests: 4, 6
Non-zero exit status: 2
Files=6, Tests=103, 3 wallclock secs ( 0.06 usr + 0.03 sys = 0.09 CPU)
Result: FAIL
Failed 1/6 test programs. 2/103 subtests failed.
gmake: *** [Makefile:882: test_dynamic] Error 2
FAIL
! Installing D/DM/DMUEY/File-Copy-Recursive-0.43.tar.gz failed. See C:\Users\zdm\AppData\Local\Temp\.cpanm\work\1524345452.15336\build.log for details. Retry with --force to force install it.
On a system with ExtUtils::MakeMaker 6.6302 installed (e.g. on a fresh perl 5.16.3) the installation of File::Copy::Recursive fails:
...
Configuring D/DM/DMUEY/File-Copy-Recursive-0.45.tar.gz with Makefile.PL
WARNING: TEST_REQUIRES is not a known parameter.
Checking if your kit is complete...
Looks good
'TEST_REQUIRES' is not a known MakeMaker parameter name.
...
Can't locate Test/File.pm in @INC (@INC contains: /home/eserte/.cpan/build/2019080711/File-Copy-Recursive-0.45-0/blib/lib /home/eserte/.cpan/build/2019080711/File-Copy-Recursive-0.45-0/blib/arch /home/eserte/.cpan/build/2019080711/File-Copy-Recursive-0.45-0/blib/lib /home/eserte/.cpan/build/2019080711/File-Copy-Recursive-0.45-0/blib/arch /opt/perl-5.16.3/lib/site_perl/5.16.3/x86_64-linux /opt/perl-5.16.3/lib/site_perl/5.16.3 /opt/perl-5.16.3/lib/5.16.3/x86_64-linux /opt/perl-5.16.3/lib/5.16.3 .) at t/01.legacy.t line 13.
BEGIN failed--compilation aborted at t/01.legacy.t line 13.
t/01.legacy.t ............. Dubious, test returned 2 (wstat 512, 0x200)
... (more test failures following) ...
Probably the problem may be fixed if ExtUtils::MakeMaker 6.64 is made a configure_requires dependency (according to https://metacpan.org/source/BINGOS/ExtUtils-MakeMaker-7.36/Changes#L1108 this is the first EUMM version understanding TEST_REQUIRES
)
I use dircopy on next systems:
Linux work 5.3.0-46-generic #38~18.04.1-Ubuntu SMP Tue Mar 31 04:17:56 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Linux localhost 4.19.0-9-amd64 #1 SMP Debian 4.19.118-2 (2020-04-29) x86_64 GNU/Linux
on first system it counts 68, on second 67.
I suppose that second system do not count current directory
dircopy( '/tmp/test', $dst )
first system counts /tmp/test
but second just take files from /tmp/test
folder and do not count it
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.