summaryrefslogtreecommitdiff
path: root/t/data
diff options
context:
space:
mode:
authorRuss Allbery <rra@cpan.org>2022-01-17 11:34:54 -0800
committerRuss Allbery <rra@cpan.org>2022-01-17 11:34:54 -0800
commit0e24930c21fe8374b8d4de5a3a349eaa4314532e (patch)
tree6b2a3c43287d8467eeeb614ddda0b54bb510f410 /t/data
parent62545b34acf312156563df17a8001b4e9975eff0 (diff)
Finish the Path::Tiny conversion
Convert the test suite to Path::Tiny and convert Test::DocKnot::Spin to Path::Iterator::Rule. Document that various module APIs now take Path::Tiny objects instead of paths, and bump the version for the backward compatibility break.
Diffstat (limited to 't/data')
-rwxr-xr-xt/data/regenerate-data39
-rw-r--r--t/data/spin/output/software/docknot/api/app-docknot.html6
2 files changed, 19 insertions, 26 deletions
diff --git a/t/data/regenerate-data b/t/data/regenerate-data
index 87ee82d..f796f8f 100755
--- a/t/data/regenerate-data
+++ b/t/data/regenerate-data
@@ -7,56 +7,51 @@
# output data using the local instance of App::DocKnot. It should be run from
# the root of the DocKnot distribution directory.
#
+# Copyright 2018-2022 Russ Allbery <rra@cpan.org>
+#
# SPDX-License-Identifier: MIT
use 5.018;
use autodie;
use warnings;
-use File::Spec;
-
use lib 'blib/lib';
use App::DocKnot;
use App::DocKnot::Generate;
use App::DocKnot::Spin;
+use Path::Tiny qw(path);
use Pod::Thread;
# For each subdirectory of t/data/generate, regenerate each file in the output
# subdirectory using the metadata subdirectory and the template matching the
# output name. Special-case the docknot subdirectory, which uses DocKnot's
# own metadata.
-my $data = File::Spec->catdir('t', 'data', 'generate');
-opendir(my $datadir, $data);
-my @packages = grep { -d File::Spec->catdir($data, $_) }
- File::Spec->no_upwards(readdir($datadir));
-closedir($datadir);
+my $data = path('t', 'data', 'generate');
+my @packages = map { $_->basename() } grep { $_->is_dir() } $data->children();
for my $package (@packages) {
my $metadata;
if ($package eq 'docknot') {
- $metadata = File::Spec->catdir('docs', 'docknot.yaml');
+ $metadata = path('docs', 'docknot.yaml');
} else {
- $metadata = File::Spec->catdir($data, $package, 'docknot.yaml');
+ $metadata = $data->child($package, 'docknot.yaml');
}
- my $output = File::Spec->catdir($data, $package, 'output');
- opendir(my $outputdir, $output);
- for my $template (File::Spec->no_upwards(readdir($outputdir))) {
+ my $output = $data->child($package, 'output');
+ for my $template (map { $_->basename() } $output->children()) {
my $docknot = App::DocKnot::Generate->new({ metadata => $metadata });
- my $outpath = File::Spec->catdir($output, $template);
- $docknot->generate_output($template, $outpath);
+ $docknot->generate_output($template, $output->child($template));
}
- closedir($outputdir);
}
# The test of spinning a tree of files uses a reference to App::DocKnot's own
# POD documentation. Regenerate the expected output in case the POD has
# changed.
-my $source = File::Spec->catdir('lib', 'App', 'DocKnot.pm');
+my $source = path('lib', 'App', 'DocKnot.pm');
my $podthread = Pod::Thread->new(navbar => 1);
my $spin = App::DocKnot::Spin::Thread->new();
my $thread;
$podthread->output_string(\$thread);
-$podthread->parse_file($source);
+$podthread->parse_file("$source");
my $html = $spin->spin_thread($thread);
# Add the additional metadata that should be added by spin.
@@ -91,10 +86,8 @@ $html =~ s{ (<body> \n) }{$1$navbar}xms;
$html =~ s{ (</body>) }{$navbar\n$address$1}xms;
# Replace the expected data file.
-my $output = File::Spec->catdir(
- 't', 'data', 'spin', 'output', 'software', 'docknot',
- 'api', 'app-docknot.html',
+my $output = path(
+ 't', 'data', 'spin', 'output', 'software', 'docknot', 'api',
+ 'app-docknot.html',
);
-open(my $fh, '>', $output);
-print {$fh} $html or die "Cannot write to $output: $!\n";
-close($fh);
+$output->spew_utf8($html);
diff --git a/t/data/spin/output/software/docknot/api/app-docknot.html b/t/data/spin/output/software/docknot/api/app-docknot.html
index 85f242f..a64d7c3 100644
--- a/t/data/spin/output/software/docknot/api/app-docknot.html
+++ b/t/data/spin/output/software/docknot/api/app-docknot.html
@@ -44,8 +44,8 @@
<h2 id="S1"><a name="S1">REQUIREMENTS</a></h2>
<p>
-Perl 5.24 or later and the modules File::BaseDir, File::ShareDir, Kwalify, and
-YAML::XS, all of which are available from CPAN.
+Perl 5.24 or later and the modules File::BaseDir, File::ShareDir, Kwalify,
+Path::Tiny, and YAML::XS, all of which are available from CPAN.
</p>
<h2 id="S2"><a name="S2">DESCRIPTION</a></h2>
@@ -95,7 +95,7 @@ Russ Allbery &lt;rra@cpan.org&gt;
<h2 id="S5"><a name="S5">COPYRIGHT AND LICENSE</a></h2>
<p>
-Copyright 2013-2021 Russ Allbery &lt;rra@cpan.org&gt;
+Copyright 2013-2022 Russ Allbery &lt;rra@cpan.org&gt;
</p>
<p>