xref: /openbsd-src/gnu/usr.bin/perl/cpan/podlators/t/docs/pod.t (revision e068048151d29f2562a32185e21a8ba885482260)
1b8851fccSafresh1#!/usr/bin/perl
2b8851fccSafresh1#
3b8851fccSafresh1# Check all POD documents for POD formatting errors.
4b8851fccSafresh1#
5b8851fccSafresh1# The canonical version of this file is maintained in the rra-c-util package,
65759b3d2Safresh1# which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.
7b8851fccSafresh1#
8b8851fccSafresh1# Written by Russ Allbery <eagle@eyrie.org>
9*e0680481Safresh1# Copyright 2019, 2021 Russ Allbery <eagle@eyrie.org>
10b46d8ef2Safresh1# Copyright 2012-2014
11b8851fccSafresh1#     The Board of Trustees of the Leland Stanford Junior University
12b8851fccSafresh1#
13b8851fccSafresh1# Permission is hereby granted, free of charge, to any person obtaining a
14b8851fccSafresh1# copy of this software and associated documentation files (the "Software"),
15b8851fccSafresh1# to deal in the Software without restriction, including without limitation
16b8851fccSafresh1# the rights to use, copy, modify, merge, publish, distribute, sublicense,
17b8851fccSafresh1# and/or sell copies of the Software, and to permit persons to whom the
18b8851fccSafresh1# Software is furnished to do so, subject to the following conditions:
19b8851fccSafresh1#
20b8851fccSafresh1# The above copyright notice and this permission notice shall be included in
21b8851fccSafresh1# all copies or substantial portions of the Software.
22b8851fccSafresh1#
23b8851fccSafresh1# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24b8851fccSafresh1# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25b8851fccSafresh1# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
26b8851fccSafresh1# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27b8851fccSafresh1# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28b8851fccSafresh1# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29b8851fccSafresh1# DEALINGS IN THE SOFTWARE.
30b46d8ef2Safresh1#
31b46d8ef2Safresh1# SPDX-License-Identifier: MIT
32b8851fccSafresh1
33*e0680481Safresh1use 5.010;
34b8851fccSafresh1use strict;
35b8851fccSafresh1use warnings;
36b8851fccSafresh1
37b8851fccSafresh1use lib 't/lib';
38b8851fccSafresh1
39b8851fccSafresh1use Test::RRA qw(skip_unless_automated use_prereq);
40b8851fccSafresh1
4156d68f1eSafresh1use Test::More;
4256d68f1eSafresh1
43b8851fccSafresh1# Skip this test for normal user installs, although pod2man may still fail.
44b8851fccSafresh1skip_unless_automated('POD syntax tests');
45b8851fccSafresh1
46b8851fccSafresh1# Load prerequisite modules.
47b8851fccSafresh1use_prereq('Test::Pod');
48b8851fccSafresh1
49*e0680481Safresh1# Check all POD in the Perl distribution.  Add the examples and t/lib
50*e0680481Safresh1# directories if they exist.  Also add any files in usr/bin or usr/sbin,
51*e0680481Safresh1# which are widely used in Stanford-internal packages.
52b8851fccSafresh1my @files = all_pod_files();
53b8851fccSafresh1if (-d 'examples') {
54b8851fccSafresh1    push(@files, all_pod_files('examples'));
55b8851fccSafresh1}
56*e0680481Safresh1if (-d File::Spec->catfile('t', 'lib')) {
57*e0680481Safresh1    push(@files, all_pod_files(File::Spec->catfile('t', 'lib')));
58*e0680481Safresh1}
59b8851fccSafresh1for my $dir (qw(usr/bin usr/sbin)) {
60b8851fccSafresh1    if (-d $dir) {
61b8851fccSafresh1        push(@files, glob("$dir/*"));
62b8851fccSafresh1    }
63b8851fccSafresh1}
64b8851fccSafresh1
65b8851fccSafresh1# We now have a list of all files to check, so output a plan and run the
66b8851fccSafresh1# tests.  We can't use all_pod_files_ok because it refuses to check non-Perl
67b8851fccSafresh1# files and Stanford-internal packages have a lot of shell scripts with POD
68b8851fccSafresh1# documentation.
69b8851fccSafresh1plan tests => scalar(@files);
70b8851fccSafresh1for my $file (@files) {
71b8851fccSafresh1    pod_file_ok($file);
72b8851fccSafresh1}
73