chiark / gitweb /
awful debugging hacking
[dpkg] / t / pod-coverage.t
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
16 use strict;
17 use warnings;
18
19 use File::Find;
20 use Dpkg::Util qw(any);
21
22 use Test::More;
23 use Test::Dpkg qw(:needs);
24
25 test_needs_author();
26 test_needs_module('Test::Pod::Coverage');
27 test_needs_srcdir_switch();
28
29 sub 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
60 my @modules_todo = qw(Dpkg::Arch Dpkg::Source::Package);
61 my @modules = all_pod_modules(@modules_todo);
62
63 plan tests => scalar @modules + scalar @modules_todo;
64
65 for my $module (@modules) {
66     pod_coverage_ok($module);
67 }
68
69 TODO: {
70     local $TODO = 'modules partially documented';
71
72     for my $module (@modules_todo) {
73         pod_coverage_ok($module);
74     }
75 }