1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../lib";
use Module::CPANTS::TestAnalyse;
my $no_symlinks;
if ($^O eq 'MSWin32') {
plan skip_all => 'requires Test::File 1.993 to test' unless eval { require Test::File; Test::File->VERSION(1.993) };
$no_symlinks = !Test::File::has_symlinks();
}
test_distribution {
my ($mca, $dir) = @_;
write_file("$dir/MANIFEST", <<"EOF");
lib/Module/CPANTS/Analyse/Test.pm
MANIFEST
EOF
write_pmfile("$dir/lib/Module/CPANTS/Analyse/Test.pm");
my $stash = $mca->run;
is $stash->{manifest_matches_dist} => 1, "manifest matches dist";
};
test_distribution {
my ($mca, $dir) = @_;
write_pmfile("$dir/lib/Module/CPANTS/Analyse/Test.pm");
my $stash = $mca->run;
is $stash->{manifest_matches_dist} => 0, "manifest does not match dist";
like $stash->{error}{manifest_matches_dist} => qr/^Cannot find MANIFEST/, "proper error message";
};
test_distribution {
my ($mca, $dir) = @_;
write_file("$dir/MANIFEST", <<"EOF");
eg/demo.pl
lib/Module/CPANTS/Analyse/Test.pm
MANIFEST
EOF
write_pmfile("$dir/lib/Module/CPANTS/Analyse/Test.pm");
write_file("$dir/TODO", "TODO!");
my $stash = $mca->run;
is $stash->{manifest_matches_dist} => 0, "manifest does not match dist";
my @errors = @{ $stash->{error}{manifest_matches_dist} || [] };
ok grep /^Missing in MANIFEST: TODO/, @errors;
ok grep /^Missing in Dist: eg\/demo\.pl/, @errors;
};
# should hide symlink errors not in MANIFEST for a local distribution
test_distribution {
my ($mca, $dir) = @_;
write_file("$dir/MANIFEST", <<"EOF");
MANIFEST
EOF
eval { symlink "$dir/MANIFEST", "$dir/MANIFEST.lnk" };
if ($@) {
diag "symlink is not supported";
return;
}
my $stash = $mca->run;
ok !$stash->{error}{symlinks}, "symlinks not listed in MANIFEST is ignored for a local distribution";
} unless $no_symlinks;
test_distribution {
my ($mca, $dir) = @_;
write_file("$dir/MANIFEST", <<"EOF");
MANIFEST
EOF
eval { symlink "$dir/MANIFEST", "$dir/MANIFEST.lnk" };
if ($@) {
diag "symlink is not supported";
return;
}
my $stash = archive_and_analyse($dir, "Module-CPANTS-Analyse-Test-0.01.tar.gz");
ok $stash->{error}{symlinks}, "symlinks not listed in MANIFEST is not ignored for a non-local distribution";
} unless $no_symlinks;
done_testing;
|