diff --git a/.mailmap b/.mailmap new file mode 100644 index 0000000..6ae016e --- /dev/null +++ b/.mailmap @@ -0,0 +1,3 @@ +# https://www.kernel.org/pub/software/scm/git/docs/git-shortlog.html +# or git help shortlog +Kent Fredric diff --git a/Changes b/Changes index fbcd1c3..e7240f3 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ Revision history for {{$dist->name}} {{$NEXT}} + - Re-Architected test suite 1.70 2014-12-31 - also skip _eumm, an artifact of ExtUtils::MakeMaker 7.05* diff --git a/t/01-filenames.t b/t/01-filenames.t new file mode 100644 index 0000000..79241c8 --- /dev/null +++ b/t/01-filenames.t @@ -0,0 +1,113 @@ +use strict; +use warnings; + +use lib 't/lib'; +use ManifestTest qw( catch_warning canon_warning spew runtemp ); +use ExtUtils::Manifest qw( maniadd maniread maniskip skipcheck mkmanifest ); +use Test::More; + +my $filenames = { + space => 'foo bar', + space_quote => 'foo\' baz\'quux', + space_backslash => 'foo bar\\baz', + space_quote_backslash => 'foo bar\\baz\'quux', + quoted_string => q{'foo quoted name.txt'}, # https://rt.perl.org/Ticket/Display.html?id=122415 +}; + +my $LAST_ERROR; + +# Return 1 if it fatalled, undef otherwise. +# Its almost bash! +# !fatal = expect not fatal. +# fatal = expect fatal +sub fatal(&) { + my ($code) = @_; + my ($ok); + { + local $@; + $ok = eval { $code->(); 1 }; + $LAST_ERROR = $@; + } + return !$ok; +} + +plan tests => ( scalar keys %{$filenames} ) * 8; + +note " \nMaking sure maniadd of file works correctly unusually named files"; +for my $testname ( sort keys %{$filenames} ) { + my $filename = $filenames->{$testname}; + + runtemp "01-filenames.maniadd.$testname" => sub { + note "Making sure maniadd of file works correctly with file named: <$filename>"; + spew( "MANIFEST", "\n" ); + maniadd( { $filename => $testname } ); + my $read = maniread; + is( scalar keys %{$read}, 1, "One file in manifest" ); + ok( exists $read->{$filename}, "file for test $testname ( $filename ) exists" ); + is( $read->{$filename}, $testname, "comment for test $testname ( $filename ) extracted correctly" ); + }; +} + +note " \nMaking sure skipcheck works correctly unusually named files"; +for my $testname ( sort keys %{$filenames} ) { + my $filename = $filenames->{$testname}; + + runtemp "01-filenames.skipcheck.$testname" => sub { + note "Making sure skipcheck can hide file with file named: <$filename> and regex ^'?foo"; + SKIP: { + spew( "MANIFEST", "\n" ); + spew( "MANIFEST.SKIP", "^'?foo\nMANIFEST.SKIP\nMANIFEST.bak\n" ); + + skip "Cant create $filename: $LAST_ERROR", 1 if fatal { spew( $filename, $testname ) }; + my $warning = catch_warning sub { skipcheck }; + like( $warning, qr/Skipping \Q$filename\E/, "skipcheck reports elective skipped files" ); + } + + }; +} + +note " \nMaking sure mkmanifest correctly skips unusually named files"; +for my $testname ( sort keys %{$filenames} ) { + my $filename = $filenames->{$testname}; + + runtemp "01-filenames.mkmanifest.skip_$testname" => sub { + note "Making sure mkmanifest can hide file with file named: <$filename> and regex ^'?foo"; + SKIP: { + spew( "MANIFEST", "\n" ); + spew( "MANIFEST.SKIP", "^'?foo\nMANIFEST.SKIP\nMANIFEST.bak\n" ); + + skip "Cant create $filename: $LAST_ERROR", 2 if fatal { spew( $filename, $testname ) }; + + my $warning = catch_warning sub { mkmanifest }; + my $read = maniread; + is( scalar keys %{$read}, 1, "One file in manifest" ); + my ( $file, ) = keys %{$read}; + + # Case insensitive for VMS + is( lc($file), "manifest", "Only manifest seen" ); + } + }; +} +note " \nMaking sure mkmanifest correctly includes unusually named files"; +for my $testname ( sort keys %{$filenames} ) { + my $filename = $filenames->{$testname}; + + runtemp "01-filenames.mkmanifest.include_$testname" => sub { + note "Making sure mkmanifest include a file named: <$filename>"; + SKIP: { + spew( "MANIFEST", "\n" ); + spew( "MANIFEST.SKIP", "MANIFEST.SKIP\nMANIFEST.bak\n" ); + skip "Cant create $filename: $LAST_ERROR", 2 if fatal { spew( $filename, $testname ) }; + + my $warning = catch_warning sub { mkmanifest }; + my $read = maniread; + is( scalar keys %{$read}, 2, "two files in manifest" ); + + # Case insensitive for VMS + my ( @got ) = sort map { lc($_) } keys %{$read}; + my ( @expected ) = sort map { lc($_) } 'MANIFEST', $filename; + + is_deeply( \@got, \@expected, "Both files returned undefiled" ); + } + }; +} diff --git a/t/Manifest.t b/t/Manifest.t index 830a786..cd7b32a 100644 --- a/t/Manifest.t +++ b/t/Manifest.t @@ -14,7 +14,7 @@ chdir 't'; use strict; -use Test::More tests => 98; +use Test::More tests => 36; use Cwd; use File::Spec; @@ -74,8 +74,8 @@ sub remove_dir { # use module, import functions BEGIN { use_ok( 'ExtUtils::Manifest', - qw( mkmanifest manicheck filecheck fullcheck - maniread manicopy skipcheck maniadd maniskip) ); + qw( mkmanifest + maniread skipcheck maniadd maniskip) ); } my $cwd = Cwd::getcwd(); @@ -85,153 +85,17 @@ rmtree('mantest'); ok( mkdir( 'mantest', 0777 ), 'make mantest directory' ); ok( chdir( 'mantest' ), 'chdir() to mantest' ); -ok( add_file('foo'), 'add a temporary file' ); -# This ensures the -x check for manicopy means something -# Some platforms don't have chmod or an executable bit, in which case -# this call will do nothing or fail, but on the platforms where chmod() -# works, we test the executable bit is copied -chmod( 0744, 'foo') if $Config{'chmod'}; - -# there shouldn't be a MANIFEST there -my ($res, $warn) = catch_warning( \&mkmanifest ); -# Canonize the order. -$warn = join("", map { "$_|" } - sort { lc($a) cmp lc($b) } split /\r?\n/, $warn); -is( $warn, "Added to MANIFEST: foo|Added to MANIFEST: MANIFEST|", - "mkmanifest() displayed its additions" ); - -# and now you see it -ok( -e 'MANIFEST', 'create MANIFEST file' ); - -my @list = read_manifest(); -is( @list, 2, 'check files in MANIFEST' ); -ok( ! ExtUtils::Manifest::filecheck(), 'no additional files in directory' ); - -# after adding bar, the MANIFEST is out of date -ok( add_file( 'bar' ), 'add another file' ); -ok( ! manicheck(), 'MANIFEST now out of sync' ); - -# it reports that bar has been added and throws a warning -($res, $warn) = catch_warning( \&filecheck ); - -like( $warn, qr/^Not in MANIFEST: bar/, 'warning that bar has been added' ); -is( $res, 'bar', 'bar reported as new' ); - -# now quiet the warning that bar was added and test again -($res, $warn) = do { local $ExtUtils::Manifest::Quiet = 1; - catch_warning( \&skipcheck ) - }; -is( $warn, '', 'disabled warnings' ); - -# add a skip file with a rule to skip itself (and the nonexistent glob '*baz*') -add_file( 'MANIFEST.SKIP', "baz\n.SKIP" ); - -# this'll skip the new file -($res, $warn) = catch_warning( \&skipcheck ); -like( $warn, qr/^Skipping MANIFEST\.SKIP/i, 'got skipping warning' ); - -my @skipped; -catch_warning( sub { - @skipped = skipcheck() -}); - -is( join( ' ', @skipped ), 'MANIFEST.SKIP', 'listed skipped files' ); - -{ - local $ExtUtils::Manifest::Quiet = 1; - is( join(' ', filecheck() ), 'bar', 'listing skipped with filecheck()' ); -} - -# add a subdirectory and a file there that should be found -ok( mkdir( 'moretest', 0777 ), 'created moretest directory' ); -add_file( File::Spec->catfile('moretest', 'quux'), 'quux' ); -ok( exists( ExtUtils::Manifest::manifind()->{'moretest/quux'} ), - "manifind found moretest/quux" ); - -# only MANIFEST and foo are in the manifest -$_ = 'foo'; -my $files = maniread(); -is( keys %$files, 2, 'two files found' ); -is( join(' ', sort { lc($a) cmp lc($b) } keys %$files), 'foo MANIFEST', - 'both files found' ); -is( $_, 'foo', q{maniread() doesn't clobber $_} ); - -ok( mkdir( 'copy', 0777 ), 'made copy directory' ); - -# Check that manicopy copies files. -manicopy( $files, 'copy', 'cp' ); -my @copies = (); -find( sub { push @copies, $_ if -f }, 'copy' ); -@copies = map { s/\.$//; $_ } @copies if $Is_VMS; # VMS likes to put dots on - # the end of files. -# Have to compare insensitively for non-case preserving VMS -is_deeply( [sort map { lc } @copies], [sort map { lc } keys %$files] ); - -# cp would leave files readonly, so check permissions. -foreach my $orig (@copies) { - my $copy = "copy/$orig"; - ok( -r $copy, "$copy: must be readable" ); - is( -w $copy, -w $orig, " writable if original was" ); - is( -x $copy, -x $orig, " executable if original was" ); -} -rmtree('copy'); - - -# poison the manifest, and add a comment that should be reported +my ($res, $warn); add_file( 'MANIFEST', 'none #none' ); -is( ExtUtils::Manifest::maniread()->{none}, '#none', - 'maniread found comment' ); - -ok( mkdir( 'copy', 0777 ), 'made copy directory' ); -$files = maniread(); -eval { (undef, $warn) = catch_warning( sub { - manicopy( $files, 'copy', 'cp' ) }) -}; - -# a newline comes through, so get rid of it -chomp($warn); -# the copy should have given a warning -like($warn, qr/^none not found/, 'carped about none' ); -($res, $warn) = catch_warning( \&skipcheck ); -like($warn, qr/^Skipping MANIFEST.SKIP/i, 'warned about MANIFEST.SKIP' ); - -# tell ExtUtils::Manifest to use a different file -{ - local $ExtUtils::Manifest::MANIFEST = 'albatross'; - ($res, $warn) = catch_warning( \&mkmanifest ); - like( $warn, qr/Added to albatross: /, 'using a new manifest file' ); - - # add the new file to the list of files to be deleted - $Files{'albatross'}++; -} - - -# Make sure MANIFEST.SKIP is using complete relative paths -add_file( 'MANIFEST.SKIP' => "^moretest/q\n" ); - -# This'll skip moretest/quux -($res, $warn) = catch_warning( \&skipcheck ); -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, '', 'MANIFEST overrides MANIFEST.SKIP, no warnings' ); - -$files = maniread; +my $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' ); my $manicontents = do { local $/; @@ -284,143 +148,41 @@ is index($manicontents, "\015\012"), -1, 'MANIFEST no CRLF'; rename "MANIFEST.bak", "MANIFEST" or die "Could not rename MANIFEST.bak to MANIFEST: $!"; } -my %funky_files; -# test including a filename with a space -SKIP: { - add_file( 'foo bar' => "space" ) - or skip "couldn't create spaced test file", 2; - local $ExtUtils::Manifest::MANIFEST = "albatross"; - maniadd({ 'foo bar' => "contains space"}); - is( maniread()->{'foo bar'}, "contains space", - 'spaced manifest filename' ); - add_file( 'albatross.bak', '' ); - ($res, $warn) = catch_warning( \&mkmanifest ); - like( $warn, qr/\A(Added to.*\n)+\z/m, - 'no warnings about funky filename' ); - $funky_files{'space'} = 'foo bar'; -} - -# test including a filename with a space and a quote -SKIP: { - add_file( 'foo\' baz\'quux' => "quote" ) - or skip "couldn't create quoted test file", 1; - local $ExtUtils::Manifest::MANIFEST = "albatross"; - maniadd({ 'foo\' baz\'quux' => "contains quote"}); - is( maniread()->{'foo\' baz\'quux'}, "contains quote", - 'quoted manifest filename' ); - $funky_files{'space_quote'} = 'foo\' baz\'quux'; -} - -# test including a filename with a space and a backslash -SKIP: { - add_file( 'foo bar\\baz' => "backslash" ) - or skip "couldn't create backslash test file", 1; - local $ExtUtils::Manifest::MANIFEST = "albatross"; - maniadd({ 'foo bar\\baz' => "contains backslash"}); - is( maniread()->{'foo bar\\baz'}, "contains backslash", - 'backslashed manifest filename' ); - $funky_files{'space_backslash'} = 'foo bar\\baz'; -} - -# test including a filename with a space, quote, and a backslash -SKIP: { - add_file( 'foo bar\\baz\'quux' => "backslash/quote" ) - or skip "couldn't create backslash/quote test file", 1; - local $ExtUtils::Manifest::MANIFEST = "albatross"; - maniadd({ 'foo bar\\baz\'quux' => "backslash and quote"}); - is( maniread()->{'foo bar\\baz\'quux'}, "backslash and quote", - 'backslashed and quoted manifest filename' ); - $funky_files{'space_quote_backslash'} = 'foo bar\\baz\'quux'; -} - -# test including a filename which is itself a quoted string -# https://rt.perl.org/Ticket/Display.html?id=122415 -SKIP: { - my $quoted_filename = q{'quoted name.txt'}; - my $description = "quoted string"; - add_file( $quoted_filename => $description ) - or skip "couldn't create $description test file", 1; - local $ExtUtils::Manifest::MANIFEST = "albatross"; - maniadd({ $quoted_filename => $description }); - is( maniread()->{$quoted_filename}, $description, - 'file whose name starts and ends with quotes' ); - $funky_files{$description} = $quoted_filename; -} - -my @funky_keys = qw(space space_quote space_backslash space_quote_backslash); # test including an external manifest.skip file in MANIFEST.SKIP { - maniadd({ foo => undef , albatross => undef, - 'mymanifest.skip' => undef, 'mydefault.skip' => undef}); - for (@funky_keys) { - maniadd( {$funky_files{$_} => $_} ) if defined $funky_files{$_}; - } - + maniadd({ foo => undef , 'mymanifest.skip' => undef, 'mydefault.skip' => undef}); + add_file('foo' => 'Blah'); add_file('mymanifest.skip' => "^foo\n"); add_file('mydefault.skip' => "^my\n"); local $ExtUtils::Manifest::DEFAULT_MSKIP = File::Spec->catfile($cwd, qw(mantest mydefault.skip)); my $skip = File::Spec->catfile($cwd, qw(mantest mymanifest.skip)); - add_file('MANIFEST.SKIP' => - "albatross\n#!include $skip\n#!include_default"); + add_file('MANIFEST.SKIP' => "#!include $skip\n#!include_default"); my ($res, $warn) = catch_warning( \&skipcheck ); - for (qw(albatross foo foobar mymanifest.skip mydefault.skip)) { + for (qw(foo mymanifest.skip mydefault.skip)) { like( $warn, qr/Skipping \b$_\b/, "Skipping $_" ); } - for my $funky_key (@funky_keys) { - SKIP: { - my $funky_file = $funky_files{$funky_key}; - skip "'$funky_key' not created", 1 unless $funky_file; - like( $warn, qr/Skipping \b\Q$funky_file\E\b/, - "Skipping $funky_file"); - } - } ($res, $warn) = catch_warning( \&mkmanifest ); - for (qw(albatross foo foobar mymanifest.skip mydefault.skip)) { + for (qw(foo mymanifest.skip mydefault.skip)) { like( $warn, qr/Removed from MANIFEST: \b$_\b/, "Removed $_ from MANIFEST" ); } - for my $funky_key (@funky_keys) { - SKIP: { - my $funky_file = $funky_files{$funky_key}; - skip "'$funky_key' not created", 1 unless $funky_file; - like( $warn, qr/Removed from MANIFEST: \b\Q$funky_file\E\b/, - "Removed $funky_file from MANIFEST"); - } - } my $files = maniread; - ok( ! exists $files->{albatross}, 'albatross excluded via MANIFEST.SKIP' ); ok( exists $files->{yarrow}, 'yarrow included in MANIFEST' ); - ok( exists $files->{bar}, 'bar included in MANIFEST' ); - ok( ! exists $files->{foobar}, 'foobar excluded via mymanifest.skip' ); ok( ! exists $files->{foo}, 'foo excluded via mymanifest.skip' ); ok( ! exists $files->{'mymanifest.skip'}, 'mymanifest.skip excluded via mydefault.skip' ); ok( ! exists $files->{'mydefault.skip'}, 'mydefault.skip excluded via mydefault.skip' ); - # test exclusion of funky files - for my $funky_key (@funky_keys) { - SKIP: { - my $funky_file = $funky_files{$funky_key}; - skip "'$funky_key' not created", 1 unless $funky_file; - ok( ! exists $files->{$funky_file}, - "'$funky_file' excluded via mymanifest.skip" ); - } - } - # tests for maniskip my $skipchk = maniskip(); - is ( $skipchk->('albatross'), 1, - 'albatross excluded via MANIFEST.SKIP' ); is( $skipchk->('yarrow'), '', 'yarrow included in MANIFEST' ); is( $skipchk->('bar'), '', 'bar included in MANIFEST' ); $skipchk = maniskip('mymanifest.skip'); - is( $skipchk->('foobar'), 1, - 'foobar excluded via mymanifest.skip' ); is( $skipchk->('foo'), 1, 'foo excluded via mymanifest.skip' ); is( $skipchk->('mymanifest.skip'), '', @@ -428,8 +190,6 @@ my @funky_keys = qw(space space_quote space_backslash space_quote_backslash); is( $skipchk->('mydefault.skip'), '', 'mydefault.skip included via mydefault.skip' ); $skipchk = maniskip('mydefault.skip'); - is( $skipchk->('foobar'), '', - 'foobar included via mydefault.skip' ); is( $skipchk->('foo'), '', 'foo included via mydefault.skip' ); is( $skipchk->('mymanifest.skip'), 1, @@ -441,42 +201,12 @@ my @funky_keys = qw(space space_quote space_backslash space_quote_backslash); $Files{"$_.bak"}++ for ('MANIFEST', "MANIFEST${extsep}SKIP"); } -add_file('MANIFEST' => 'Makefile.PL'); -maniadd({ foo => 'bar' }); -$files = maniread; -# VMS downcases the MANIFEST. We normalize it here to match. -%$files = map { (lc $_ => $files->{$_}) } keys %$files; -my %expect = ( 'makefile.pl' => '', - 'foo' => 'bar' - ); -is_deeply( $files, \%expect, 'maniadd() vs MANIFEST without trailing newline'); - -#add_file('MANIFEST' => 'Makefile.PL'); -#maniadd({ foo => 'bar' }); - -SKIP: { - chmod( 0400, 'MANIFEST' ); - skip "Can't make MANIFEST read-only", 2 if -w 'MANIFEST' or $Config{osname} eq 'cygwin'; - - eval { - maniadd({ 'foo' => 'bar' }); - }; - is( $@, '', "maniadd() won't open MANIFEST if it doesn't need to" ); - - eval { - maniadd({ 'grrrwoof' => 'yippie' }); - }; - like( $@, qr/^\Qmaniadd() could not open MANIFEST:\E/, - "maniadd() dies if it can't open the MANIFEST" ); - - chmod( 0600, 'MANIFEST' ); -} - - END { - is( unlink( keys %Files ), keys %Files, 'remove all added files' ); + note "remove all files"; + for my $file ( sort keys %Files ) { + is(( unlink $file ), 1, "Unlink $file") or note "$!"; + } for my $file ( keys %Files ) { 1 while unlink $file; } # all versions - remove_dir( 'moretest', 'copy' ); # now get rid of the parent directory ok( chdir( $cwd ), 'return to parent directory' ); diff --git a/t/filecheck.t b/t/filecheck.t new file mode 100644 index 0000000..5e29343 --- /dev/null +++ b/t/filecheck.t @@ -0,0 +1,59 @@ +use strict; +use warnings; + +use lib 't/lib'; +use ManifestTest qw( catch_warning canon_warning spew runtemp ); +use ExtUtils::Manifest qw( filecheck ); +use Test::More tests => 11; + +runtemp "filecheck.emptydir" => sub { + note "Empty dir check"; + my (@extra); + my ( $out, $warning ) = catch_warning sub { @extra = filecheck() }; + ok( !@extra, 'no extra files' ) or do { + diag $_ for @extra; + }; +}; + +runtemp "filecheck.blank_manifest" => sub { + note "Blank Manifest File"; + spew( "MANIFEST", "" ); + my (@extra); + my ( $out, $warning ) = catch_warning sub { @extra = filecheck() }; + ok( @extra, 'filecheck vs blank MANIFEST == extra files' ); + is( canon_warning($warning), "Not in MANIFEST: MANIFEST|", "Manifest warns about not being in itself" ); +}; + +runtemp "filecheck.self_manifest" => sub { + note "Self-Containing Manifest File"; + spew( "MANIFEST", "MANIFEST" ); + my (@extra); + my ( $out, $warning ) = catch_warning sub { @extra = filecheck() }; + ok( !@extra, 'filecheck vs self-containing MANIFEST no extras' ); + is( $warning, '', "No warnings" ); +}; + +runtemp "filecheck.surplus_file" => sub { + note "A Surplus file not in the manifest"; + spew( "MANIFEST", "MANIFEST" ); + spew( "not_in_manifest", "Content" ); + my (@extra); + my ( $out, $warning ) = catch_warning sub { @extra = filecheck() }; + ok( @extra, 'Extra files reported' ); + is( lc( $extra[0] ), 'not_in_manifest', "File reported missing" ); + is( canon_warning($warning), "Not in MANIFEST: not_in_manifest|", "Manifest warns about missing file" ); +}; + +runtemp "filecheck.surplus_file_nowarnings" => sub { + note "A Surplus file not in the manifest with warnings disabled"; + spew( "MANIFEST", "MANIFEST" ); + spew( "not_in_manifest", "Content" ); + my (@extra); + my ( $out, $warning ) = catch_warning sub { + local $ExtUtils::Manifest::Quiet = 1; + @extra = filecheck(); + }; + ok( @extra, 'Extra files reported' ); + is( lc( $extra[0] ), 'not_in_manifest', "File reported missing" ); + is( $warning, '', "No Warning" ); +}; diff --git a/t/lib/ManifestTest.pm b/t/lib/ManifestTest.pm new file mode 100644 index 0000000..f03f085 --- /dev/null +++ b/t/lib/ManifestTest.pm @@ -0,0 +1,90 @@ +use strict; +use warnings; + +package ManifestTest; + +# ABSTRACT: Manifest Testing Utilities + +use Cwd qw( getcwd abs_path ); +use File::Temp qw(); +use File::Path qw( rmtree ); +use Exporter; + +our @ISA = qw( Exporter ); +our @EXPORT_OK = qw( catch_warning canon_warning spew runtemp slurp ); +my $Is_VMS = $^O eq 'VMS'; +my $Is_VMS_noefs = $Is_VMS; +if ($Is_VMS) { + my $vms_efs = 0; + if ( eval 'require VMS::Feature' ) { + $vms_efs = VMS::Feature::current("efs_charset"); + } + else { + my $efs_charset = $ENV{'DECC$EFS_CHARSET'} || ''; + $vms_efs = $efs_charset =~ /^[ET1]/i; + } + $Is_VMS_noefs = 0 if $vms_efs; +} + +sub runtemp { + my ( $label, $code ) = @_; + my $old = getcwd(); + my $tempdir = File::Temp::tempdir( + 'ManifestTest.' . $label . '.XXXXX', + DIR => 't/', + CLEANUP => 0 + ); + my $abs = abs_path($tempdir); + chdir $tempdir; + local $@; + my $bailed = 1; + eval { $code->(); $bailed = 0 }; + chdir $old; + + if ( not $bailed ) { + rmtree( $tempdir, 0, 1 ); + return; + } + die "runtemp $label failed: $@\n tempdir left in place\n\t$abs\nstopped "; +} + +sub catch_warning { + my $warn = ''; + local $SIG{__WARN__} = sub { $warn .= $_[0] }; + join( '', $_[0]->() ), $warn; +} + +sub canon_warning { + my ($warn) = @_; + join( "", map { "$_|" } sort { lc($a) cmp lc($b) } split /\r?\n/, $warn ); +} + +sub spew { + my ( $path, $data ) = @_; + if ( ( ref $path || '' ) eq 'ARRAY' ) { + require File::Spec; + $path = File::Spec->catfile(@{$path}); + } + $data = 'foo' unless defined $data; + $path =~ s/ /^_/g if $Is_VMS_noefs; # escape spaces + 1 while unlink $path; # or else we'll get multiple versions on VMS + open my $fh, '>', $path or die "Can't write $path"; + binmode $fh, ':raw'; # no CRLFs please + print {$fh} $data; + close $fh; + die unless -e $path; # exists under the name we gave it ? +} + +sub slurp { + my ($path) = @_; + $path =~ s/ /^_/g if $Is_VMS_noefs; # escape spaces + die "No such file $path" unless -e $path; + open my $fh, '<', $path or die "Can't read $path"; + binmode $fh, ':raw'; + my $content = do { local $/; <$fh> }; + close $fh; + return $content; +} + +1; + diff --git a/t/maniadd.t b/t/maniadd.t new file mode 100644 index 0000000..6c2b724 --- /dev/null +++ b/t/maniadd.t @@ -0,0 +1,90 @@ +use strict; +use warnings; + +use lib 't/lib'; +use ManifestTest qw( catch_warning canon_warning spew runtemp ); +use ExtUtils::Manifest qw( maniadd maniread ); +use Config; +use Test::More tests => 8; + +my $LAST_ERROR; + +# Return 1 if it fatalled, undef otherwise. +# Its almost bash! +# !fatal = expect not fatal. +# fatal = expect fatal +sub fatal(&) { + my ($code) = @_; + my ($ok); + { + local $@; + $ok = eval { $code->(); 1 }; + $LAST_ERROR = $@; + } + return !$ok; +} + +runtemp "maniadd.unneeded_readonly" => sub { + note "Ensuring maniadd does not need to write to a file for existing entries"; + + spew( "MANIFEST", "foo #bar\n" ); +SKIP: { + chmod( 0400, "MANIFEST" ); + + if ( -w "MANIFEST" or $Config{osname} eq "cygwin" ) { + skip "Cant make manifest readonly", 5; + } + + ok( !fatal { maniadd( { "foo" => "bar" } ) }, "maniadd() wont die adding an existing key" ) + or diag $LAST_ERROR; + + ok( !-w "MANIFEST", "MANIFEST is still readonly" ); + + ok( fatal { maniadd( { "grrrwoof" => "yippie" } ) }, "maniadd will die adding a new key" ) + or diag $LAST_ERROR; + + like( $LAST_ERROR, qr/^\Qmaniadd() could not open MANIFEST:\E/, "maniadd dies with the expected warning" ); + + ok( !-w "MANIFEST", "MANIFEST is still readonly" ); + + chmod( 0600, 'MANIFEST' ); + } + +}; + +runtemp "maniadd.unneeded_readonly_notrailingeol" => sub { + note "Ensuring maniadd does not arbitrarily make a file writeable if it lacks an EOL"; + local $TODO = "Broken, GH #13"; + spew( "MANIFEST", "foo #bar" ); +SKIP: { + chmod( 0400, "MANIFEST" ); + + if ( -w "MANIFEST" or $Config{osname} eq "cygwin" ) { + skip "Cant make manifest readonly", 5; + } + ok( !fatal { maniadd( { "foo" => "bar" } ) }, "maniadd() wont die adding an existing key" ) + or diag $LAST_ERROR; + + ok( !-w "MANIFEST", "MANIFEST is still readonly" ); + + chmod( 0600, "MANIFEST" ); + + } + +}; + +runtemp "maniadd.auto_add_newlines" => sub { + note "Ensuring lack of a trailing source newline does not break maniadd"; + spew( "MANIFEST", "initial_content" ); + maniadd( { "newfile", "newcomment" } ); + + my $read = maniread; + + # VMS downcases the MANIFEST. We normalize it here to match. + my (%got) = map { lc $_ => $read->{$_} } keys %{$read}; + my (%expected) = ( + "initial_content" => "", + "newfile" => "newcomment" + ); + is_deeply( \%got, \%expected, "maniadd added new entries to MANIFEST with newline included" ); +}; diff --git a/t/manicheck.t b/t/manicheck.t new file mode 100644 index 0000000..79dc1a1 --- /dev/null +++ b/t/manicheck.t @@ -0,0 +1,48 @@ +use strict; +use warnings; + +use lib 't/lib'; +use ManifestTest qw( catch_warning canon_warning spew runtemp ); +use ExtUtils::Manifest qw( manicheck ); +use Test::More tests => 6; + +runtemp "manicheck.blank_manifest" => sub { + note "Blank Manifest File"; + spew( "MANIFEST", "" ); + my (@missing) = manicheck(); + ok( !@missing, 'manicheck vs blank MANIFEST file in otherwise empty dir == OK! No missing files' ); +}; + +runtemp "manicheck.self_manifest" => sub { + note "Self-Containing Manifest File"; + spew( "MANIFEST", "MANIFEST" ); + my (@missing) = manicheck(); + ok( !@missing, 'manicheck vs self-containing MANIFEST ok' ); +}; + +runtemp "manicheck.missing_file" => sub { + note "Manifest file with more files than on disk"; + spew( "MANIFEST", "MANIFEST\nNo_Such_File" ); + my (@missing); + my ( $out, $err ) = catch_warning( sub { @missing = manicheck() } ); + cmp_ok( scalar @missing, '==', 1, 'manicheck with missing file returns list' ); + cmp_ok( $missing[0], 'eq', 'No_Such_File', 'No_Such_File reported missing' ); +}; + +# There was a bug where entries in MANIFEST would be blotted out +# by MANIFEST.SKIP rules. +runtemp "manicheck.skipped_file" => sub { + note "Manifest file with files that are maniskipped"; + spew( "MANIFEST", "file_a\n" ); + spew( "MANIFEST.SKIP", "file_a\n" ); + spew( "file_a", "Some content" ); + + my (@missing); + my ( $out, $err ) = catch_warning( sub { @missing = manicheck() } ); + cmp_ok( scalar @missing, '==', 0, 'skipfile doesnt show file_a as missing' ) + or do { + note $_ for @missing; + }; + cmp_ok( $err, 'eq', '', 'no warnings' ); +}; + diff --git a/t/manicopy.t b/t/manicopy.t new file mode 100644 index 0000000..23aaf96 --- /dev/null +++ b/t/manicopy.t @@ -0,0 +1,60 @@ +use strict; +use warnings; + +use lib 't/lib'; +use ManifestTest qw( catch_warning canon_warning spew slurp runtemp ); +use ExtUtils::Manifest qw( manicopy ); +use Test::More tests => 16; +use Config; + +runtemp "manicopy.emptylist" => sub { + note "Sanity check running manicopy with no work to do"; + ok( ( mkdir 'target', 0700 ), 'make target dir ok' ); + my ( $exit, $warn ) = catch_warning sub { manicopy( {}, 'target' ) }; + is( $warn, '', 'No-op = no warning' ); +}; + +runtemp "manicopy.basic" => sub { + note "Copying a file"; + ok( ( mkdir 'target', 0700 ), 'make target dir ok' ); + spew( 'file', "####" ); + my $source = 'file'; + my $target = 'target/file'; + + my ( $exit, $warn ) = catch_warning sub { manicopy( { 'file' => 'description' }, 'target', 'cp' ) }; + is( $warn, '', 'no warning' ); + ok( -e $target, 'Copied ok' ); + is( slurp($target), '####', 'Content preserved' ); + ok( -r $target, 'Copied file should be readable' ); + is( -x $target, -x $source, '-x bits copied' ); + is( -w $target, -w $source, '-w bits copied' ); +}; + +runtemp "manicopy.executable" => sub { + note "Copying a file that might have -x bits"; + +SKIP: { + # This ensures the -x check for manicopy means something + # Some platforms don't have chmod or an executable bit, in which case + # this call will do nothing or fail, but on the platforms where chmod() + # works, we test the executable bit is copied + + skip "No Exec bits support for copy test", 5 unless $Config{'chmod'}; + + ok( ( mkdir 'target', 0700 ), 'make target dir ok' ); + spew( 'execfile', "####" ); + chmod( 0744, 'execfile' ); + ok( -x 'execfile', 'Created an -x file' ); + my ( $exit, $warn ) = catch_warning sub { manicopy( { 'execfile' => 'description' }, 'target' ) }; + is( $warn, '', 'no warning' ); + ok( -e 'target/execfile', 'Copied ok' ); + ok( -x 'target/execfile', '-x bits copied' ); + } +}; + +runtemp 'manicopy.warn_missing' => sub { + note "Copying a file that doesn't exist"; + ok( ( mkdir 'target', 0700 ), 'make target dir ok' ); + my ( $exit, $warn ) = catch_warning sub { manicopy( { none => 'none' }, 'target', 'cp' ) }; + like( $warn, qr/^none not found/, 'carped about missing file' ); +}; diff --git a/t/maniread.t b/t/maniread.t new file mode 100644 index 0000000..d615de8 --- /dev/null +++ b/t/maniread.t @@ -0,0 +1,75 @@ +use strict; +use warnings; + +use lib 't/lib'; +use ManifestTest qw( catch_warning canon_warning spew runtemp ); +use ExtUtils::Manifest qw( maniread ); +use Test::More tests => 10; + +runtemp "maniread.basic_read" => sub { + note "Basic use of maniread"; + spew( 'MANIFEST', "file_a\nMANIFEST" ); + my $files = maniread(); + is( keys %$files, 2, 'two files found' ); + is( join( ' ', sort { lc($a) cmp lc($b) } keys %$files ), 'file_a MANIFEST', 'both files found' ); +}; + +runtemp "maniread.basic_read_noclobber_context" => sub { + note "Making sure maniread doesnt clobber \$_"; + my $old = $_; + $_ = "foo"; + + spew( 'MANIFEST', "file_a\nMANIFEST" ); + my $files = maniread(); + is( keys %$files, 2, 'two files found' ); + is( join( ' ', sort { lc($a) cmp lc($b) } keys %$files ), 'file_a MANIFEST', 'both files found' ); + + is( $_, 'foo', q{maniread() doesn't clobber $_} ); + $_ = $old; +}; + +runtemp "maniread.comments" => sub { + note "Extracting comments from a manifest"; + + spew( 'MANIFEST', 'file_a #comment for file a' ); + my $files = maniread(); + is( $files->{file_a}, '#comment for file a', 'mani read found comment' ); +}; + +runtemp "maniread.spaced_file" => sub { + note "Parsing a manifest with a file with a space in it"; + + spew( 'MANIFEST', "'file with space' this is a comment" ); + my $files = maniread(); + + is( $files->{'file with space'}, 'this is a comment', 'File name extracted distinctly' ); +}; + +runtemp "maniread.space_and_quote_file" => sub { + note "Parsing a manifest with a file with literal quotes and spaces"; + + spew( 'MANIFEST', "'file\\' with\\' space' this is a comment" ); + my $files = maniread(); + + is( $files->{'file\' with\' space'}, 'this is a comment', 'File name extracted distinctly' ); +}; + +runtemp "maniread.space_and_backslash_file" => sub { + note "Parsing a manifest with a file literal backslashes and spaces"; + + spew( 'MANIFEST', "'file\\\\ with\\\\ space' this is a comment" ); + my $files = maniread(); + + is( $files->{'file\\ with\\ space'}, 'this is a comment', 'File name extracted distinctly' ); +}; + +# test including a filename which is itself a quoted string +# https://rt.perl.org/Ticket/Display.html?id=122415 +runtemp "maniread.quoted_filename" => sub { + note "Parsing a manifest with a filename which is itself a quoted string"; + + spew( 'MANIFEST', "'\\\'file with space\\\'' this is a comment" ); + my $files = maniread(); + + is( $files->{'\'file with space\''}, 'this is a comment', 'File name extracted distinctly' ); +}; diff --git a/t/mkmanifest.t b/t/mkmanifest.t new file mode 100644 index 0000000..eced448 --- /dev/null +++ b/t/mkmanifest.t @@ -0,0 +1,94 @@ +use strict; +use warnings; + +use lib 't/lib'; +use ManifestTest qw( catch_warning canon_warning spew slurp runtemp ); +use ExtUtils::Manifest qw( mkmanifest ); +use Test::More tests => 16; + +runtemp "mkmanifest.empty" => sub { + note "empty mkmanifest dir"; + + my ( $res, $warn ) = catch_warning( \&mkmanifest ); + is( canon_warning($warn), "Added to MANIFEST: MANIFEST|", "mkmanifest() displayed its additions" ); + + ok( -e 'MANIFEST', 'create MANIFEST file' ); +}; + +runtemp "mkmanifest.existing_file" => sub { + note "mkmanifest dir with existing content"; + + spew( 'foo', 'foo' ); + + my ( $res, $warn ) = catch_warning( \&mkmanifest ); + + is( canon_warning($warn), "Added to MANIFEST: foo|Added to MANIFEST: MANIFEST|", "mkmanifest() displayed its additions" ); + + ok( -e 'MANIFEST', 'create MANIFEST file' ); +}; + +runtemp "mkmanifest.existing_manifest" => sub { + note "mkmanifest dir with existing MANIFEST file"; + + spew( 'MANIFEST', 'foo' ); + + my ( $res, $warn ) = catch_warning( \&mkmanifest ); + + is( canon_warning($warn), "Added to MANIFEST: MANIFEST|", "mkmanifest() displayed its additions" ); + + ok( -e 'MANIFEST', 'create MANIFEST file' ); + ok( -e 'MANIFEST.bak', 'existing MANIFEST file backed up' ); +}; + +runtemp "mkmanifest.custom_filename" => sub { + note "mkmanifest with custom filename defined"; + + local $ExtUtils::Manifest::MANIFEST = 'albatross'; + + my ( $res, $warn ) = catch_warning( \&mkmanifest ); + + is( canon_warning($warn), "Added to albatross: albatross|", "mkmanifest() displayed its additions to an atypical filename" ); + ok( -e 'albatross', 'atypical manifest \'albatross\' created' ); +}; + +runtemp "mkmanifest.autoadd_spacefiles" => sub { + note "mkmanifest with a dir with files with spaces in them"; +SKIP: { + eval { spew( "space space", "foo" ); 1 } + or skip "Cant create spaced file", 2; + my ( $res, $warn ) = catch_warning( \&mkmanifest ); + + is( + canon_warning($warn), + "Added to MANIFEST: MANIFEST|Added to MANIFEST: space space|", + "mkmanifest() displayed its additions" + ); + ok( -e 'MANIFEST', 'create MANIFEST file' ); + + } +}; + +runtemp "mkmanifest.autoremove" => sub { + note "mkmanifest removing files on skip list"; + + spew( "file_a", "File A Contents" ); + spew( "file_b", "File A Contents" ); + spew( "MANIFEST.SKIP", "" ); + + my ( $res, $warn ) = catch_warning( \&mkmanifest ); + + is( + canon_warning($warn), + ( join q[], map { "Added to MANIFEST: $_|" } qw(file_a file_b MANIFEST MANIFEST.SKIP ) ), + "mkmanifest() displayed its additions" + ); + ok( -e 'MANIFEST', 'create MANIFEST file' ); + spew( "MANIFEST.SKIP", "MANIFEST.bak\nfile_a" ); + ( $res, $warn ) = catch_warning( \&mkmanifest ); + + is( canon_warning($warn), "Removed from MANIFEST: file_a|", "mkmanifest() displayed its removals" ); + ok( -e 'MANIFEST', 'MANIFEST still exists' ); + my @generated = split /\r?\n/, slurp('MANIFEST'); + ok( ( !grep { $_ =~ /file_a/ } @generated ), 'file_a stripped from MANIFEST' ); +}; + diff --git a/t/skipcheck.t b/t/skipcheck.t new file mode 100644 index 0000000..a91bb2f --- /dev/null +++ b/t/skipcheck.t @@ -0,0 +1,214 @@ +use strict; +use warnings; + +use lib 't/lib'; +use ManifestTest qw( catch_warning canon_warning spew slurp runtemp ); +use ExtUtils::Manifest qw( skipcheck ); +use Cwd qw(); +use Test::More tests => 40; + +# Yes, most of these cases do the same thing. +# skipcheck doesn't do anything in any of the below cases. +runtemp "skipcheck.emptydir" => sub { + note "Skipcheck an empty dir"; + my (@items); + my ( $exit, $warn ) = catch_warning sub { @items = skipcheck }; + ok( !@items, "no items" ); + is( $warn, '', 'no warning' ); +}; + +runtemp "skipcheck.emptymanifest" => sub { + note "Skipcheck a dir with empty manifest"; + spew( "MANIFEST", "" ); + my (@items); + my ( $exit, $warn ) = catch_warning sub { @items = skipcheck }; + ok( !@items, "no items" ); + + is( $warn, '', 'no warning' ); +}; + +runtemp "skipcheck.selfmanifest" => sub { + note "Skipcheck a dir with self-containing manifest"; + spew( "MANIFEST", "MANIFEST" ); + my (@items); + my ( $exit, $warn ) = catch_warning sub { @items = skipcheck }; + ok( !@items, "no items" ); + is( $warn, '', 'no warning' ); +}; + +runtemp "skipcheck.fileonly" => sub { + note "Skipcheck a dir with a non-manifest file"; + spew( "foo", "garbage" ); + my (@items); + my ( $exit, $warn ) = catch_warning sub { @items = skipcheck }; + ok( !@items, "no items" ); + is( $warn, '', 'no warning' ); +}; + +runtemp "skipcheck.extrafile" => sub { + note "Skipcheck a dir with a manifest missing a file"; + spew( "MANIFEST", "MANIFEST" ); + spew( "foo", "garbage" ); + my (@items); + my ( $exit, $warn ) = catch_warning sub { @items = skipcheck }; + ok( !@items, "no items" ); + is( $warn, '', 'no warning' ); +}; + +runtemp "skipcheck.emptymanifest.emptyskip" => sub { + note "Skipcheck a dir with empty manifest and empty skipfile"; + spew( "MANIFEST", "" ); + spew( "MANIFEST.SKIP", "" ); + my (@items); + my ( $exit, $warn ) = catch_warning sub { @items = skipcheck }; + ok( !@items, "no items" ); + + is( $warn, '', 'no warning' ); +}; + +runtemp "skipcheck.selfmanifest.emptyskip" => sub { + note "Skipcheck a dir with self-containing manifest and empty skipfile"; + spew( "MANIFEST", "MANIFEST" ); + spew( "MANIFEST.SKIP", "" ); + + my (@items); + my ( $exit, $warn ) = catch_warning sub { @items = skipcheck }; + ok( !@items, "no items" ); + is( $warn, '', 'no warning' ); +}; + +runtemp "skipcheck.fileonly.emptyskip" => sub { + note "Skipcheck a dir with a non-manifest file and empty skipfile"; + spew( "foo", "garbage" ); + spew( "MANIFEST.SKIP", "" ); + + my (@items); + my ( $exit, $warn ) = catch_warning sub { @items = skipcheck }; + ok( !@items, "no items" ); + is( $warn, '', 'no warning' ); +}; + +runtemp "skipcheck.extrafile.emptyskip" => sub { + note "Skipcheck a dir with a manifest missing a file and empty skipfile"; + spew( "MANIFEST", "MANIFEST" ); + spew( "foo", "garbage" ); + spew( "MANIFEST.SKIP", "" ); + + my (@items); + my ( $exit, $warn ) = catch_warning sub { @items = skipcheck }; + ok( !@items, "no items" ); + is( $warn, '', 'no warning' ); +}; + +runtemp "skipcheck.selfmanifest.selfskip" => sub { + note "Skipcheck a dir with self-containing manifest and self-containing skipfile"; + spew( "MANIFEST", "MANIFEST" ); + spew( "MANIFEST.SKIP", "MANIFEST.SKIP" ); + + my (@items); + my ( $exit, $warn ) = catch_warning sub { @items = skipcheck }; + cmp_ok( scalar @items, '==', 1, "Exactly one skip result" ); + cmp_ok( uc $items[0], 'eq', 'MANIFEST.SKIP', "report skipping MANIFEST.SKIP" ); + like( canon_warning($warn), qr/^Skipping MANIFEST\.SKIP\|/i, 'Warning expected' ); +}; + +runtemp "skipcheck.selfmanifest.selfskip.quiet" => sub { + note "Skipcheck a dir with self-containing manifest and self-containing skipfile when quietened"; + spew( "MANIFEST", "MANIFEST" ); + spew( "MANIFEST.SKIP", "MANIFEST.SKIP" ); + + my (@items); + my ( $exit, $warn ) = catch_warning sub { + local $ExtUtils::Manifest::Quiet = 1; + @items = skipcheck; + }; + cmp_ok( scalar @items, '==', 1, "Exactly one skip result" ); + cmp_ok( uc $items[0], 'eq', 'MANIFEST.SKIP', "report skipping MANIFEST.SKIP" ); + is( $warn, '', 'Warning silenced' ); +}; + +runtemp "skipcheck.relative_paths" => sub { + note "make sure MANIFEST.SKIP uses relative paths in regex"; +SKIP: { + ok( ( mkdir 'moretest', 0777 ), 'created test dir' ) or skip "Cant create dir", 4; + eval { spew( [ 'moretest', 'quux' ] => 'Some content' ); 1 } or skip "Cant create file in dir", 3; + spew( 'MANIFEST', '' ); + spew( 'MANIFEST.SKIP', "^moretest/q\n" ); + my (@items); + my ( $exit, $warn ) = catch_warning sub { @items = skipcheck }; + cmp_ok( scalar @items, '==', 1, "Exactly one skip result" ); + cmp_ok( lc $items[0], 'eq', 'moretest/quux', "report skipping moretest/quux" ); + like( canon_warning($warn), qr/^Skipping moretest\/quux\|/i, 'Warning expected' ); + } +}; + +runtemp "skipcheck.include_default" => sub { + note "ensuring #include_default works in skipcheck"; + spew( 'MANIFEST', '' ); + spew( 'Makefile', '' ); + spew( 'mymanifest.skip', "Makefile\n" ); + spew( 'MANIFEST.SKIP', "#!include_default" ); + + my (@items); + my ( $exit, $warn ) = catch_warning sub { + local $ExtUtils::Manifest::DEFAULT_MSKIP = File::Spec->catfile( Cwd::getcwd, 'mymanifest.skip' ); + @items = skipcheck; + }; + cmp_ok( scalar @items, '==', 1, 'Exactly one skip result' ); + cmp_ok( lc $items[0], 'eq', 'makefile', "report skipping Makefile" ); + like( canon_warning($warn), qr/^Skipping Makefile\|/i, 'Warning expected' ); + +}; + +runtemp "skipcheck.include_default_noeol" => sub { + note "ensuring #include_default works in skipcheck with unterminated files"; + local $TODO = "Broken, GH #14"; + spew( 'MANIFEST', '' ); + spew( 'Makefile', '' ); + spew( 'mymanifest.skip', "Makefile" ); + spew( 'MANIFEST.SKIP', "#!include_default" ); + + my (@items); + my ( $exit, $warn ) = catch_warning sub { + local $ExtUtils::Manifest::DEFAULT_MSKIP = File::Spec->catfile( Cwd::getcwd, 'mymanifest.skip' ); + @items = skipcheck; + }; + cmp_ok( scalar @items, '==', 1, 'Exactly one skip result' ); + cmp_ok( lc( $items[0] || '' ), 'eq', 'makefile', "report skipping Makefile" ); + like( canon_warning($warn), qr/^Skipping Makefile\|/i, 'Warning expected' ); + +}; + +runtemp "skipcheck.include" => sub { + note "ensuring #include works in skipcheck"; + + spew( 'MANIFEST', 'MANIFEST.SKIP' ); + spew( 'Makefile', 'content' ); + spew( 'mymanifest.skip', "Makefile\n" ); + spew( 'MANIFEST.SKIP', "#!include mymanifest.skip" ); + + my (@items); + my ( $exit, $warn ) = catch_warning sub { @items = skipcheck }; + cmp_ok( scalar @items, '==', 1, 'Exactly one skip result' ) or note explain \@items; + cmp_ok( lc $items[0], 'eq', 'makefile', "report skipping Makefile" ); + like( canon_warning($warn), qr/^Skipping Makefile\|/i, 'Warning expected' ); + +}; +runtemp "skipcheck.include_dir" => sub { + note "ensuring #include works in skipcheck with a file in a dir"; + + spew( 'MANIFEST', 'MANIFEST.SKIP' ); + mkdir "mantest"; + + spew( 'Makefile', 'content' ); + spew( [ 'mantest', 'mymanifest.skip' ], "Makefile\n" ); + spew( 'MANIFEST.SKIP', "#!include mantest/mymanifest.skip" ); + + my (@items); + my ( $exit, $warn ) = catch_warning sub { @items = skipcheck }; + cmp_ok( scalar @items, '==', 1, 'Exactly one skip result' ) or note explain \@items; + cmp_ok( lc $items[0], 'eq', 'makefile', "report skipping Makefile" ); + like( canon_warning($warn), qr/^Skipping Makefile\|/i, 'Warning expected' ); + +}; +