Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor tests #12

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.kernel.org/pub/software/scm/git/docs/git-shortlog.html
# or git help shortlog
Kent Fredric <[email protected]> <[email protected]>
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -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*
Expand Down
113 changes: 113 additions & 0 deletions t/01-filenames.t
Original file line number Diff line number Diff line change
@@ -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" );
}
};
}
Loading