summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorRuss Allbery <rra@cpan.org>2020-01-07 23:26:14 -0800
committerRuss Allbery <rra@cpan.org>2020-01-07 23:26:14 -0800
commitb7e0d657f052522d9366eb0b324c35e2675a3a48 (patch)
tree32dbc547e2c9705c3d886eeeb43d545acc05d605 /t
parent5e2e5380ddc3c4f906db6313788a678d40a82140 (diff)
Check for files missing from the dist
docknot dist now checks for files present in the source tree but missing from the distribution, apart from a (currently hard-coded) list of exceptions.
Diffstat (limited to 't')
-rw-r--r--t/data/dist/MANIFEST3
-rwxr-xr-xt/dist/basic.t43
2 files changed, 37 insertions, 9 deletions
diff --git a/t/data/dist/MANIFEST b/t/data/dist/MANIFEST
index ab9b270..7ae2399 100644
--- a/t/data/dist/MANIFEST
+++ b/t/data/dist/MANIFEST
@@ -1,5 +1,8 @@
Build.PL
+docs/metadata/blurb
+docs/metadata/description
docs/metadata/metadata.json
+docs/metadata/requirements
lib/Empty.pm
MANIFEST This list of files
MANIFEST.SKIP
diff --git a/t/dist/basic.t b/t/dist/basic.t
index 3279ef1..939a1e1 100755
--- a/t/dist/basic.t
+++ b/t/dist/basic.t
@@ -60,7 +60,7 @@ if ($@ || !$result) {
chdir($cwd);
plan skip_all => 'git and tar not available';
} else {
- plan tests => 5;
+ plan tests => 12;
}
# Load the module. Change back to the starting directory for this so that
@@ -76,16 +76,41 @@ open(my $fh, '>', File::Spec->catfile($distdir, 'Empty', 'Build.PL'));
close($fh);
chmod(0000, File::Spec->catfile($distdir, 'Empty', 'Build.PL'));
-# Setup finished. Now we can create a distribution tarball. Be careful to
-# change working directories before letting $dir go out of scope so that
-# cleanup works properly.
+# Setup finished. Now we can create a distribution tarball.
chdir($sourcedir);
-eval {
- my $dist = App::DocKnot::Dist->new({ distdir => $distdir, perl => $^X });
- capture_stdout { $dist->make_distribution() };
-};
+my $dist = App::DocKnot::Dist->new({ distdir => $distdir, perl => $^X });
+eval { capture_stdout { $dist->make_distribution() } };
ok(-f File::Spec->catfile($distdir, 'Empty-1.00.tar.gz'), 'dist exists');
ok(-f File::Spec->catfile($distdir, 'Empty-1.00.tar.xz'), 'xz dist exists');
ok(!-f File::Spec->catfile($distdir, 'Empty-1.00.tar'), 'tarball missing');
-chdir($cwd);
is($@, q{}, 'no errors');
+
+# If we add a new file to the source tree and run make_distribution() again,
+# it should fail, and the output should contain an error message about an
+# unknown file.
+open($fh, '>', 'some-file');
+print {$fh} "Some data\n" or die "cannot write to some-file: $!\n";
+close($fh);
+my $stdout = capture_stdout { eval { $dist->make_distribution() } };
+is($@, "1 file missing from distribution\n", 'correct error for extra file');
+like($stdout, qr{ some-file }xms, 'output mentions the right file');
+
+# Verify that check_dist produces the same output.
+my $tarball = File::Spec->catfile($distdir, 'Empty-1.00.tar.gz');
+my @missing = $dist->check_dist($sourcedir, $tarball);
+is_deeply(['some-file'], \@missing, 'check_dist matches');
+
+# Another missing file should produce different formatting.
+open($fh, '>', 'another-file');
+print {$fh} "Some data\n" or die "cannot write to some-file: $!\n";
+close($fh);
+$stdout = capture_stdout { eval { $dist->make_distribution() } };
+is($@, "2 files missing from distribution\n", 'correct error for two files');
+like($stdout, qr{ some-file }xms, 'output mentions the first file');
+like($stdout, qr{ another-file }xms, 'output mentions the other file');
+@missing = $dist->check_dist($sourcedir, $tarball);
+is_deeply(['another-file', 'some-file'], \@missing, 'check_dist matches');
+
+# Be careful to change working directories before letting $dir go out of scope
+# so that cleanup works properly.
+chdir($cwd);