use strict;
# these files help the test run
-use Test::More tests => 32;
+use Test::More tests => 37;
use Cwd;
# these files are needed for the module itself
use File::Spec;
use File::Path;
-use Carp::Heavy;
+
+# We're going to be chdir'ing and modules are sometimes loaded on the
+# fly in this test, so we need an absolute @INC.
+@INC = map { File::Spec->rel2abs($_) } @INC;
# keep track of everything added so it can all be deleted
my %files;
sub add_file {
- my ($file, $data) = @_;
- $data ||= 'foo';
+ my ($file, $data) = @_;
+ $data ||= 'foo';
unlink $file; # or else we'll get multiple versions on VMS
- open( my $T, '>', $file) or return;
- print $T $data;
- ++$files{$file};
+ open( T, '>'.$file) or return;
+ print T $data;
+ ++$files{$file};
+ close T;
}
sub read_manifest {
- open( my $M, 'MANIFEST' ) or return;
- chomp( my @files = <$M> );
+ open( M, 'MANIFEST' ) or return;
+ chomp( my @files = <M> );
+ close M;
return @files;
}
BEGIN {
use_ok( 'ExtUtils::Manifest',
qw( mkmanifest manicheck filecheck fullcheck
- maniread manicopy skipcheck ) );
+ maniread manicopy skipcheck maniadd) );
}
my $cwd = Cwd::getcwd();
($res, $warn) = catch_warning( \&skipcheck );
like( $warn, qr/^Skipping MANIFEST\.SKIP/i, 'got skipping warning' );
-# I'm not sure why this should be... shouldn't $missing be the only one?
-my ($found, $missing );
+my @skipped;
catch_warning( sub {
- ( $found, $missing ) = skipcheck()
+ @skipped = skipcheck()
});
-# nothing new should be found, bar should be skipped
-is( @$found, 0, 'no output here' );
-is( join( ' ', @$missing ), 'bar', 'listed skipped files' );
+is( join( ' ', @skipped ), 'MANIFEST.SKIP', 'listed skipped files' );
{
local $ExtUtils::Manifest::Quiet = 1;
$files = maniread();
eval { (undef, $warn) = catch_warning( sub {
- manicopy( $files, 'copy', 'cp' ) })
+ manicopy( $files, 'copy', 'cp' ) })
};
-like( $@, qr/^Can't read none: /, 'carped about none' );
+like( $@, qr/^Can't read none: /, 'croaked about none' );
# a newline comes through, so get rid of it
chomp($warn);
# This'll skip moretest/quux
($res, $warn) = catch_warning( \&skipcheck );
-like( $warn, qr{^Skipping moretest/quux}i, 'got skipping warning again' );
+like( $warn, qr{^Skipping moretest/quux$}i, 'got skipping warning again' );
+
+
+# There was a bug where entries in MANIFEST would be blotted out
+# by MANIFEST.SKIP rules.
+add_file( 'MANIFEST.SKIP' => 'foo' );
+add_file( 'MANIFEST' => "foobar\n" );
+add_file( 'foobar' => '123' );
+($res, $warn) = catch_warning( \&manicheck );
+is( $res, '', 'MANIFEST overrides MANIFEST.SKIP' );
+is( $warn, undef, 'MANIFEST overrides MANIFEST.SKIP, no warnings' );
+
+$files = maniread;
+ok( !$files->{wibble}, 'MANIFEST in good state' );
+maniadd({ wibble => undef });
+maniadd({ yarrow => "hock" });
+$files = maniread;
+is( $files->{wibble}, '', 'maniadd() with undef comment' );
+is( $files->{yarrow}, 'hock',' with comment' );
+is( $files->{foobar}, '', ' preserved old entries' );
END {