pod-coverage.t 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 Dpkg::Util qw(any);
  19. use Test::More;
  20. use Test::Dpkg qw(:needs);
  21. test_needs_author();
  22. test_needs_module('Test::Pod::Coverage');
  23. test_needs_srcdir_switch();
  24. sub all_pod_modules
  25. {
  26. my @modules_todo = @_;
  27. my @modules;
  28. my $scan_perl_modules = sub {
  29. my $module = $File::Find::name;
  30. # Only chack modules, scripts are documented in man pages.
  31. return unless $module =~ s/\.pm$//;
  32. # As a first step just check public modules (version > 0.xx).
  33. return unless system('grep', '-q', '^our \$VERSION = \'[^0]\.',
  34. $File::Find::name) == 0;
  35. $module =~ s{^\Q$File::Find::topdir\E/}{};
  36. $module =~ s{/}{::}g;
  37. return if any { $module eq $_ } @modules_todo;
  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_todo = qw(Dpkg::Arch Dpkg::Source::Package);
  48. my @modules = all_pod_modules(@modules_todo);
  49. plan tests => scalar @modules + scalar @modules_todo;
  50. for my $module (@modules) {
  51. pod_coverage_ok($module);
  52. }
  53. TODO: {
  54. local $TODO = 'modules partially documented';
  55. for my $module (@modules_todo) {
  56. pod_coverage_ok($module);
  57. }
  58. }