App-DocKnot
view release on metacpan or search on metacpan
t/dist/basic.t view on Meta::CPAN
} else {
plan tests => 20;
}
# Load the module now that we're sure we can run tests.
require_ok('App::DocKnot::Dist');
# Put some existing files in the directory that are marked read-only. These
# should be cleaned up automatically.
$distdir->child('Empty')->mkpath();
$distdir->child('Empty', 'Build.PL')->touch()->chmod(0000);
# Setup finished. Now we can create a distribution tarball.
chdir($sourcedir);
my $dist = App::DocKnot::Dist->new({ distdir => $distdir, perl => $^X });
capture_stdout {
eval { $dist->make_distribution() };
};
ok($distdir->child('Empty-v2.0.0.tar.gz')->exists(), 'dist exists');
ok($distdir->child('Empty-v2.0.0.tar.xz')->exists(), 'xz dist exists');
ok(!$distdir->child('Empty-v2.0.0.tar')->exists(), 'tarball missing');
t/lib/Test/DocKnot/Spin.pm view on Meta::CPAN
# tree. Fix permissions as we go to allow writes since when building a
# distribution the original file may be read-only.
#
# $tree - Path::Tiny pointing to a tree of files containing pointers
# $base - Base path of the original input tree as a Path::Tiny object
sub fix_pointers {
my ($tree, $base) = @_;
my $rule = Path::Iterator::Rule->new()->name('*.spin')->file();
my $iter = $rule->iter("$tree", { follow_symlinks => 0 });
while (defined(my $file = $iter->())) {
chmod(0644, $file);
my $data_ref = YAML::XS::LoadFile($file);
my $path = path($data_ref->{path});
my $top = path($file)->parent()->relative($tree)->absolute($base);
$data_ref->{path} = $path->absolute($top)->realpath()->stringify();
YAML::XS::DumpFile($file, $data_ref);
}
return;
}
# Compare an output file with expected file contents, with modifications for
t/spin/tree.t view on Meta::CPAN
utime(time() - 5, time() - 5, $pointer_path)
or die "Cannot reset timestamps of $pointer_path: $!\n";
# Now, update the .versions file at the top of the input tree to change the
# timestamp to ten seconds into the future. This should force regeneration of
# only the software/docknot/index.html file.
my $versions_path = $tmpdir->child('.versions');
my $versions = $versions_path->slurp_utf8();
my $new_date = strftime('%Y-%m-%d %T', localtime(time() + 10));
$versions =~ s{ \d{4}-\d\d-\d\d [ ] [\d:]+ }{$new_date}xms;
$versions_path->chmod(0644);
$versions_path->spew_utf8($versions);
$stdout = capture_stdout { $spin->spin($tmpdir, $output) };
is(
$stdout,
"Spinning .../software/docknot/index.html\n",
'Spinning again regenerates the DocKnot page',
);
# Report the end of testing.
done_testing($count + 12);
( run in 0.419 second using v1.01-cache-2.11-cpan-496ff517765 )