Skip to content

Commit 7806eaf

Browse files
committed
Pull out manicopy tests
1 parent d227ad7 commit 7806eaf

File tree

2 files changed

+65
-39
lines changed

2 files changed

+65
-39
lines changed

t/Manifest.t

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ chdir 't';
1414

1515
use strict;
1616

17-
use Test::More tests => 92;
17+
use Test::More tests => 81;
1818
use Cwd;
1919

2020
use File::Spec;
@@ -75,7 +75,7 @@ sub remove_dir {
7575
BEGIN {
7676
use_ok( 'ExtUtils::Manifest',
7777
qw( mkmanifest
78-
maniread manicopy skipcheck maniadd maniskip) );
78+
maniread skipcheck maniadd maniskip) );
7979
}
8080

8181
my $cwd = Cwd::getcwd();
@@ -87,14 +87,7 @@ ok( mkdir( 'mantest', 0777 ), 'make mantest directory' );
8787
ok( chdir( 'mantest' ), 'chdir() to mantest' );
8888
ok( add_file('foo'), 'add a temporary file' );
8989

90-
# This ensures the -x check for manicopy means something
91-
# Some platforms don't have chmod or an executable bit, in which case
92-
# this call will do nothing or fail, but on the platforms where chmod()
93-
# works, we test the executable bit is copied
94-
chmod( 0744, 'foo') if $Config{'chmod'};
95-
9690
my ($res, $warn);
97-
9891
add_file('MANIFEST',<<'EOF');
9992
foo
10093
MANIFEST
@@ -132,38 +125,11 @@ add_file( File::Spec->catfile('moretest', 'quux'), 'quux' );
132125
ok( exists( ExtUtils::Manifest::manifind()->{'moretest/quux'} ),
133126
"manifind found moretest/quux" );
134127

135-
my $files = maniread();
136-
ok( mkdir( 'copy', 0777 ), 'made copy directory' );
137-
138-
# Check that manicopy copies files.
139-
manicopy( $files, 'copy', 'cp' );
140-
my @copies = ();
141-
find( sub { push @copies, $_ if -f }, 'copy' );
142-
@copies = map { s/\.$//; $_ } @copies if $Is_VMS; # VMS likes to put dots on
143-
# the end of files.
144-
# Have to compare insensitively for non-case preserving VMS
145-
is_deeply( [sort map { lc } @copies], [sort map { lc } keys %$files] );
146-
147-
# cp would leave files readonly, so check permissions.
148-
foreach my $orig (@copies) {
149-
my $copy = "copy/$orig";
150-
ok( -r $copy, "$copy: must be readable" );
151-
is( -w $copy, -w $orig, " writable if original was" );
152-
is( -x $copy, -x $orig, " executable if original was" );
153-
}
154-
rmtree('copy');
128+
155129
add_file( 'MANIFEST', 'none #none' );
156-
ok( mkdir( 'copy', 0777 ), 'made copy directory' );
157130

158-
$files = maniread();
159-
eval { (undef, $warn) = catch_warning( sub {
160-
manicopy( $files, 'copy', 'cp' ) })
161-
};
131+
my $files = maniread();
162132

163-
# a newline comes through, so get rid of it
164-
chomp($warn);
165-
# the copy should have given a warning
166-
like($warn, qr/^none not found/, 'carped about none' );
167133
($res, $warn) = catch_warning( \&skipcheck );
168134
like($warn, qr/^Skipping MANIFEST.SKIP/i, 'warned about MANIFEST.SKIP' );
169135

@@ -426,7 +392,7 @@ END {
426392
is(( unlink $file ), 1, "Unlink $file") or note "$!";
427393
}
428394
for my $file ( keys %Files ) { 1 while unlink $file; } # all versions
429-
remove_dir( 'moretest', 'copy' );
395+
remove_dir( 'moretest');
430396

431397
# now get rid of the parent directory
432398
ok( chdir( $cwd ), 'return to parent directory' );

t/manicopy.t

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
use strict;
2+
use warnings;
3+
4+
use lib 't/lib';
5+
use ManifestTest qw( catch_warning canon_warning spew slurp runtemp );
6+
use ExtUtils::Manifest qw( manicopy );
7+
use Test::More tests => 16;
8+
use Config;
9+
10+
runtemp "manicopy.emptylist" => sub {
11+
note "Sanity check running manicopy with no work to do";
12+
ok( ( mkdir 'target', 0700 ), 'make target dir ok' );
13+
my ( $exit, $warn ) = catch_warning sub { manicopy( {}, 'target' ) };
14+
is( $warn, '', 'No-op = no warning' );
15+
};
16+
17+
runtemp "manicopy.basic" => sub {
18+
note "Copying a file";
19+
ok( ( mkdir 'target', 0700 ), 'make target dir ok' );
20+
spew( 'file', "####" );
21+
my $source = 'file';
22+
my $target = 'target/file';
23+
24+
my ( $exit, $warn ) = catch_warning sub { manicopy( { 'file' => 'description' }, 'target', 'cp' ) };
25+
is( $warn, '', 'no warning' );
26+
ok( -e $target, 'Copied ok' );
27+
is( slurp($target), '####', 'Content preserved' );
28+
ok( -r $target, 'Copied file should be readable' );
29+
is( -x $target, -x $source, '-x bits copied' );
30+
is( -w $target, -w $source, '-w bits copied' );
31+
};
32+
33+
runtemp "manicopy.executable" => sub {
34+
note "Copying a file that might have -x bits";
35+
36+
SKIP: {
37+
# This ensures the -x check for manicopy means something
38+
# Some platforms don't have chmod or an executable bit, in which case
39+
# this call will do nothing or fail, but on the platforms where chmod()
40+
# works, we test the executable bit is copied
41+
42+
skip "No Exec bits support for copy test", 5 unless $Config{'chmod'};
43+
44+
ok( ( mkdir 'target', 0700 ), 'make target dir ok' );
45+
spew( 'execfile', "####" );
46+
chmod( 0744, 'execfile' );
47+
ok( -x 'execfile', 'Created an -x file' );
48+
my ( $exit, $warn ) = catch_warning sub { manicopy( { 'execfile' => 'description' }, 'target' ) };
49+
is( $warn, '', 'no warning' );
50+
ok( -e 'target/execfile', 'Copied ok' );
51+
ok( -x 'target/execfile', '-x bits copied' );
52+
}
53+
};
54+
55+
runtemp 'manicopy.warn_missing' => sub {
56+
note "Copying a file that doesn't exist";
57+
ok( ( mkdir 'target', 0700 ), 'make target dir ok' );
58+
my ( $exit, $warn ) = catch_warning sub { manicopy( { none => 'none' }, 'target', 'cp' ) };
59+
like( $warn, qr/^none not found/, 'carped about missing file' );
60+
};

0 commit comments

Comments
 (0)