pod-coverage.t 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. use strict;
  16. use warnings;
  17. use File::Find;
  18. use Test::More;
  19. use Test::Dpkg qw(:needs);
  20. test_needs_author();
  21. test_needs_module('Test::Pod::Coverage');
  22. test_needs_srcdir_switch();
  23. sub all_pod_modules
  24. {
  25. my @modules;
  26. my $scan_perl_modules = sub {
  27. my $module = $File::Find::name;
  28. # Only chack modules, scripts are documented in man pages.
  29. return unless $module =~ s/\.pm$//;
  30. # As a first step just check public modules (version > 0.xx).
  31. return unless system('grep', '-q', '^our \$VERSION = \'[^0]\.',
  32. $File::Find::name) == 0;
  33. $module =~ s{^\Q$File::Find::topdir\E/}{};
  34. $module =~ s{/}{::}g;
  35. # Do not check partially private modules.
  36. return if $module eq 'Dpkg::Arch';
  37. return if $module eq 'Dpkg::Source::Package';
  38. push @modules, $module;
  39. };
  40. my %options = (
  41. wanted => $scan_perl_modules,
  42. no_chdir => 1,
  43. );
  44. find(\%options, Test::Dpkg::test_get_perl_dirs());
  45. return @modules;
  46. }
  47. my @modules = all_pod_modules();
  48. plan tests => scalar @modules;
  49. for my $module (@modules) {
  50. pod_coverage_ok($module);
  51. }