From: Steve Peters Date: Tue, 3 Oct 2006 13:06:06 +0000 (+0000) Subject: Update to ExtUtils-Command-1.11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=f353a419ab395e938eafc6160a3502642b35d964;p=p5sagit%2Fp5-mst-13.2.git Update to ExtUtils-Command-1.11 p4raw-id: //depot/perl@28918 --- diff --git a/MANIFEST b/MANIFEST index a07bd39..edc3f8f 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1618,11 +1618,11 @@ lib/ExtUtils/t/backwards.t Check MakeMaker's backwards compatibility lib/ExtUtils/t/basic.t See if MakeMaker can build a module lib/ExtUtils/t/build_man.t Set if MakeMaker builds manpages lib/ExtUtils/t/bytes.t Test ExtUtils::MakeMaker::bytes -lib/ExtUtils/t/Command.t See if ExtUtils::Command works (Win32 only) lib/ExtUtils/t/config.t Test ExtUtils::MakeMaker::Config lib/ExtUtils/t/Constant.t See if ExtUtils::Constant works lib/ExtUtils/t/dir_target.t Verify if dir_target() is supported lib/ExtUtils/t/Embed.t See if ExtUtils::Embed and embedding works +lib/ExtUtils/t/eu_command.t See if ExtUtils::Command works lib/ExtUtils/testlib.pm Fixes up @INC to use just-built extension lib/ExtUtils/t/FIRST_MAKEFILE.t See if FIRST_MAKEFILE works lib/ExtUtils/t/hints.t See if hint files are honored. diff --git a/lib/ExtUtils/Command.pm b/lib/ExtUtils/Command.pm index ecd7813..053f28e 100644 --- a/lib/ExtUtils/Command.pm +++ b/lib/ExtUtils/Command.pm @@ -10,9 +10,9 @@ use File::Path qw(rmtree); require Exporter; use vars qw(@ISA @EXPORT @EXPORT_OK $VERSION); @ISA = qw(Exporter); -@EXPORT = qw(cp rm_f rm_rf mv cat eqtime mkpath touch test_f chmod +@EXPORT = qw(cp rm_f rm_rf mv cat eqtime mkpath touch test_f test_d chmod dos2unix); -$VERSION = '1.09'; +$VERSION = '1.11'; my $Is_VMS = $^O eq 'VMS'; @@ -22,16 +22,17 @@ ExtUtils::Command - utilities to replace common UNIX commands in Makefiles etc. =head1 SYNOPSIS - perl -MExtUtils::Command -e cat files... > destination - perl -MExtUtils::Command -e mv source... destination - perl -MExtUtils::Command -e cp source... destination - perl -MExtUtils::Command -e touch files... - perl -MExtUtils::Command -e rm_f files... - perl -MExtUtils::Command -e rm_rf directories... - perl -MExtUtils::Command -e mkpath directories... - perl -MExtUtils::Command -e eqtime source destination - perl -MExtUtils::Command -e test_f file - perl -MExtUtils::Command -e chmod mode files... + perl -MExtUtils::Command -e cat files... > destination + perl -MExtUtils::Command -e mv source... destination + perl -MExtUtils::Command -e cp source... destination + perl -MExtUtils::Command -e touch files... + perl -MExtUtils::Command -e rm_f files... + perl -MExtUtils::Command -e rm_rf directories... + perl -MExtUtils::Command -e mkpath directories... + perl -MExtUtils::Command -e eqtime source destination + perl -MExtUtils::Command -e test_f file + perl -MExtUtils::Command -e test_d directory + perl -MExtUtils::Command -e chmod mode files... ... =head1 DESCRIPTION @@ -46,8 +47,6 @@ I perl -MExtUtils::Command -e 'some_command qw(some files to work on)' -For that use L. - Filenames with * and ? will be glob expanded. =over 4 @@ -62,9 +61,7 @@ sub expand_wildcards } -=item cat - - cat file ... +=item cat Concatenates all files mentioned on command line to STDOUT. @@ -76,11 +73,9 @@ sub cat () print while (<>); } -=item eqtime - - eqtime source destination +=item eqtime src dst -Sets modified time of destination to that of source. +Sets modified time of dst to that of src =cut @@ -91,11 +86,9 @@ sub eqtime utime((stat($src))[8,9],$dst); } -=item rm_rf +=item rm_rf files.... - rm_rf files or directories ... - -Removes files and directories - recursively (even if readonly) +Removes directories - recursively (even if readonly) =cut @@ -105,9 +98,7 @@ sub rm_rf rmtree([grep -e $_,@ARGV],0,0); } -=item rm_f - - rm_f file ... +=item rm_f files.... Removes files (even if readonly) @@ -124,7 +115,7 @@ sub rm_f { chmod(0777, $file); next if _unlink($file); - + carp "Cannot delete $file: $!"; } } @@ -140,9 +131,7 @@ sub _unlink { } -=item touch - - touch file ... +=item touch files ... Makes files exist, with current timestamp @@ -158,10 +147,7 @@ sub touch { } } -=item mv - - mv source_file destination_file - mv source_file source_file destination_dir +=item mv source... destination Moves source to destination. Multiple sources are allowed if destination is an existing directory. @@ -184,12 +170,9 @@ sub mv { return !$nok; } -=item cp - - cp source_file destination_file - cp source_file source_file destination_dir +=item cp source... destination -Copies sources to the destination. Multiple sources are allowed if +Copies source to destination. Multiple sources are allowed if destination is an existing directory. Returns true if all copies succeeded, false otherwise. @@ -210,9 +193,7 @@ sub cp { return $nok; } -=item chmod - - chmod mode files ... +=item chmod mode files... Sets UNIX like permissions 'mode' on all the files. e.g. 0666 @@ -241,11 +222,9 @@ sub chmod { chmod(oct $mode,@ARGV) || die "Cannot chmod ".join(' ',$mode,@ARGV).":$!"; } -=item mkpath - - mkpath directory ... +=item mkpath directory... -Creates directories, including any parent directories. +Creates directory, including any parent directories. =cut @@ -255,9 +234,7 @@ sub mkpath File::Path::mkpath([@ARGV],0,0777); } -=item test_f - - test_f file +=item test_f file Tests if a file exists @@ -268,9 +245,18 @@ sub test_f exit !-f $ARGV[0]; } -=item dos2unix +=item test_d directory + +Tests if a directory exists + +=cut - dos2unix files or dirs ... +sub test_d +{ + exit !-d $ARGV[0]; +} + +=item dos2unix Converts DOS and OS/2 linefeeds to Unix style recursively. @@ -304,16 +290,21 @@ sub dos2unix { =back -=head1 SEE ALSO +=head1 BUGS -Shell::Command which is these same functions but take arguments normally. +Should probably be Auto/Self loaded. + +=head1 SEE ALSO +ExtUtils::MakeMaker, ExtUtils::MM_Unix, ExtUtils::MM_Win32 =head1 AUTHOR Nick Ing-Simmons C -Currently maintained by Michael G Schwern C. +Maintained by Michael G Schwern C within the +ExtUtils-MakeMaker package and, as a separate CPAN package, by +Randy Kobes C. =cut diff --git a/lib/ExtUtils/t/Command.t b/lib/ExtUtils/t/eu_command.t similarity index 91% rename from lib/ExtUtils/t/Command.t rename to lib/ExtUtils/t/eu_command.t index 275b73a..4004c7b 100644 --- a/lib/ExtUtils/t/Command.t +++ b/lib/ExtUtils/t/eu_command.t @@ -23,14 +23,14 @@ BEGIN { } BEGIN { - use Test::More tests => 38; + use Test::More tests => 41; use File::Spec; } BEGIN { # bad neighbor, but test_f() uses exit() - *CORE::GLOBAL::exit = ''; # quiet 'only once' warning. - *CORE::GLOBAL::exit = sub { return $_[0] }; + *CORE::GLOBAL::exit = ''; # quiet 'only once' warning. + *CORE::GLOBAL::exit = sub { return @_ }; use_ok( 'ExtUtils::Command' ); } @@ -53,16 +53,19 @@ BEGIN { is( scalar( $$out =~ s/use_ok\( 'ExtUtils::Command'//g), 2, 'concatenation worked' ); - # the truth value here is reversed -- Perl true is shell false + # the truth value here is reversed -- Perl true is C false @ARGV = ( $Testfile ); ok( test_f(), 'testing non-existent file' ); + @ARGV = ( $Testfile ); + cmp_ok( ! test_f(), '==', (-f $Testfile), 'testing non-existent file' ); + # these are destructive, have to keep setting @ARGV @ARGV = ( $Testfile ); touch(); @ARGV = ( $Testfile ); - ok( !test_f(), 'now creating that file' ); + ok( test_f(), 'now creating that file' ); is_deeply( \@ARGV, [$Testfile], 'test_f preserves @ARGV' ); @ARGV = ( $Testfile ); @@ -105,7 +108,7 @@ BEGIN { $^O eq 'NetWare' || $^O eq 'dos' || $^O eq 'cygwin' || $^O eq 'MacOS' ) { - skip( "different file permission semantics on $^O", 4); + skip( "different file permission semantics on $^O", 3); } # change a file to execute-only @@ -159,33 +162,40 @@ BEGIN { is( ((stat('testdir'))[2] & 07777) & 0700, 0100, 'change a dir to execute-only' ); - # change a dir to write-only - @ARGV = ( '0200', 'testdir' ); + # change a dir to read-only + @ARGV = ( '0400', 'testdir' ); ExtUtils::Command::chmod(); is( ((stat('testdir'))[2] & 07777) & 0700, - ($^O eq 'vos' ? 0700 : 0200), 'change a dir to write-only' ); + ($^O eq 'vos' ? 0500 : 0400), 'change a dir to read-only' ); - # change a dir to read-only - @ARGV = ( '0400', 'testdir' ); + # change a dir to write-only + @ARGV = ( '0200', 'testdir' ); ExtUtils::Command::chmod(); is( ((stat('testdir'))[2] & 07777) & 0700, - ($^O eq 'vos' ? 0500 : 0400), 'change a dir to read-only' ); + ($^O eq 'vos' ? 0700 : 0200), 'change a dir to write-only' ); @ARGV = ('testdir'); rm_rf; - ok( ! -e 'testdir', 'rm_rf can delete a read-only dir' ); } # mkpath - @ARGV = ( File::Spec->join( 'ecmddir', 'temp2' ) ); + my $test_dir = File::Spec->join( 'ecmddir', 'temp2' ); + @ARGV = ( $test_dir ); ok( ! -e $ARGV[0], 'temp directory not there yet' ); + ok( test_d(), 'testing non-existent directory' ); + + @ARGV = ( $test_dir ); + cmp_ok( ! test_d(), '==', (-d $test_dir), 'testing non-existent dir' ); + @ARGV = ( $test_dir ); mkpath(); ok( -e $ARGV[0], 'temp directory created' ); + cmp_ok( test_d(), '==', (-d $test_dir), 'testing existing dir' ); + @ARGV = ( $test_dir ); # copy a file to a nested subdirectory unshift @ARGV, $Testfile; @orig_argv = @ARGV;