ExtUtils::MakeMaker 6.03 -> 6.06_05ish
[p5sagit/p5-mst-13.2.git] / lib / ExtUtils / t / Manifest.t
index 8c0246f..4d76b94 100644 (file)
@@ -14,28 +14,33 @@ chdir 't';
 use strict;
 
 # these files help the test run
-use Test::More tests => 33;
+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;
 }
 
@@ -53,7 +58,7 @@ sub remove_dir {
 BEGIN { 
     use_ok( 'ExtUtils::Manifest', 
             qw( mkmanifest manicheck filecheck fullcheck 
-                maniread manicopy skipcheck ) ); 
+                maniread manicopy skipcheck maniadd) ); 
 }
 
 my $cwd = Cwd::getcwd();
@@ -136,9 +141,9 @@ ok( mkdir( 'copy', 0777 ), 'made copy directory' );
 
 $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);
@@ -168,12 +173,21 @@ 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'   );
+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 {
        # the args are evaluated in scalar context