Coder Social home page Coder Social logo

p5-file-copy-recursive's People

Contributors

chorny avatar drmuey avatar ehickeycp avatar jkeenan avatar jmaslak avatar karenetheridge avatar manwar avatar plicease avatar tomhukins avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

p5-file-copy-recursive's Issues

tests fail with old Path ::Tiny on Windows

# 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.

$File::Copy::Recursive::CopyLink

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.

Behavior change in 0.39 breaks Dist::Zilla tests

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

Makefile.PL's `TEST_REQUIRES` requires a modern ExtUtils::MakeMaker

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

Testing relies on UMASK

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   

write tests for legacy code

The repo now has t/02* files to make it easier to implement tests for each function. pull requests über welcome!

  • will need to factor in the globals default and alternate values
  • will need to factor in various bad input and error conditions
  • must include specific tests all the rts mentioned in commit messages since 0.38:
  • 218aaa2 rt 97155: don't treat names that are entirely 3 or more dots as . or ..
  • 5cdf17d rt 77811: more correctly handle .. in recursion check
  • 5ae2662 rt 73881: remove existing symlink before creating it since symlink() fails otherwise
  • 0af1e8a rt 76446: fix maxlength bug, thanks lleblanc
  • 7c37db6 rt 75112: extend 8bf278c by at least changing the permissions of the readonly dir
  • 8bf278c rt 41778: propgate failures from in accessable files in recursion
  • bc32ed5 rt 70326: use File::Glob::glob() instead of glob() to avoid CORE::glob’s split-on-WS behavior
  • 8114d2c rt 86366: more POD fixes
  • 23dfcc5 rt 94343: apply POD fix patch from nicolasherry, thanks
  • 7300a01 rt 59402: make _glob funcitons exportable as documented
  • a8a0646 rt 59493: make readline() calls taint safe
  • c3aff4e rt 43328: Make pathmk work w/ UNC paths w/ simpler fix from rt 37482
  • 04f5b60 rt 43328: Make pathmk work w/ UNC paths

Win32: need to skip tests that readlink()

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.

v0.44 t/01.legacy.t fails on older-perl NetBSD

Windows 10, MSYS2 failed test 'rcopy_glob() calls rcopy for each file in the glob'

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

Recursive.pm line 376

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.

Ability to skip existing files

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.

0.43 tests under strawberry perl

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.

EUMM prereq version needs to be set

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)

Different systems count files differently

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.