dpkg (1.18.25) stretch; urgency=medium
[dpkg] / t / pod-coverage.t
CommitLineData
1479465f
GJ
1#!/usr/bin/perl
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <https://www.gnu.org/licenses/>.
15
16use strict;
17use warnings;
18
19use File::Find;
20use Dpkg::Util qw(any);
21
22use Test::More;
23use Test::Dpkg qw(:needs);
24
25test_needs_author();
26test_needs_module('Test::Pod::Coverage');
27test_needs_srcdir_switch();
28
29sub all_pod_modules
30{
31 my @modules_todo = @_;
32 my @modules;
33 my $scan_perl_modules = sub {
34 my $module = $File::Find::name;
35
36 # Only chack modules, scripts are documented in man pages.
37 return unless $module =~ s/\.pm$//;
38
39 # As a first step just check public modules (version > 0.xx).
40 return unless system('grep', '-q', '^our \$VERSION = \'[^0]\.',
41 $File::Find::name) == 0;
42
43 $module =~ s{^\Q$File::Find::topdir\E/}{};
44 $module =~ s{/}{::}g;
45
46 return if any { $module eq $_ } @modules_todo;
47
48 push @modules, $module;
49 };
50
51 my %options = (
52 wanted => $scan_perl_modules,
53 no_chdir => 1,
54 );
55 find(\%options, Test::Dpkg::test_get_perl_dirs());
56
57 return @modules;
58}
59
60my @modules_todo = qw(Dpkg::Arch Dpkg::Source::Package);
61my @modules = all_pod_modules(@modules_todo);
62
63plan tests => scalar @modules + scalar @modules_todo;
64
65for my $module (@modules) {
66 pod_coverage_ok($module);
67}
68
69TODO: {
70 local $TODO = 'modules partially documented';
71
72 for my $module (@modules_todo) {
73 pod_coverage_ok($module);
74 }
75}