ExtUtils-MakeMaker
view release on metacpan or search on metacpan
t/eu_command.t view on Meta::CPAN
# cp should croak if destination isn't directory (not a great warning)
@ARGV = ( $Testfile ) x 3;
eval { cp() };
like( $@, qr/Too many arguments/, 'cp croaks on error' );
# move a file to a subdirectory
@ARGV = ( $Testfile, 'ecmddir' );
@orig_argv = @ARGV;
ok( mv() );
is_deeply( \@ARGV, \@orig_argv, 'mv preserves @ARGV' );
ok( ! -e $Testfile, 'moved file away' );
ok( -e File::Spec->join( 'ecmddir', $Testfile ), 'file in new location' );
# mv should also croak with the same wacky warning
@ARGV = ( $Testfile ) x 3;
eval { mv() };
like( $@, qr/Too many arguments/, 'mv croaks on error' );
# Test expand_wildcards()
{
my $file = $Testfile;
@ARGV = ();
chdir 'ecmddir';
# % means 'match one character' on VMS. Everything else is ?
my $match_char = $^O eq 'VMS' ? '%' : '?';
($ARGV[0] = $file) =~ s/.\z/$match_char/;
# this should find the file
ExtUtils::Command::expand_wildcards();
is_deeply( \@ARGV, [$file], 'expanded wildcard ? successfully' );
# try it with the asterisk now
($ARGV[0] = $file) =~ s/.{3}\z/\*/;
ExtUtils::Command::expand_wildcards();
is_deeply( \@ARGV, [$file], 'expanded wildcard * successfully' );
chdir File::Spec->updir;
}
# remove some files
my @files = @ARGV = ( File::Spec->catfile( 'ecmddir', $Testfile ),
File::Spec->catfile( 'ecmddir', 'temp2', $Testfile ) );
rm_f();
ok( ! -e $_, "removed $_ successfully" ) for (@ARGV);
# rm_f dir
@ARGV = my $dir = File::Spec->catfile( 'ecmddir' );
rm_rf();
ok( ! -e $dir, "removed $dir successfully" );
}
{
{ local @ARGV = 'd2utest'; mkpath; }
open(FILE, '>d2utest/foo');
binmode(FILE);
print FILE "stuff\015\012and thing\015\012";
close FILE;
open(FILE, '>d2utest/bar');
binmode(FILE);
my $bin = "\c@\c@\c@\c@\c@\c@\cA\c@\c@\c@\015\012".
"\@\c@\cA\c@\c@\c@8__LIN\015\012";
print FILE $bin;
close FILE;
local @ARGV = 'd2utest';
ExtUtils::Command::dos2unix();
open(FILE, 'd2utest/foo');
is( join('', <FILE>), "stuff\012and thing\012", 'dos2unix' );
close FILE;
open(FILE, 'd2utest/bar');
binmode(FILE);
ok( -B 'd2utest/bar' );
is( join('', <FILE>), $bin, 'dos2unix preserves binaries');
close FILE;
}
END {
1 while unlink $Testfile, 'newfile';
File::Path::rmtree( 'ecmddir' ) if -e 'ecmddir';
File::Path::rmtree( 'd2utest' ) if -e 'd2utest';
}
( run in 2.772 seconds using v1.01-cache-2.11-cpan-8f98c5d2c55 )