This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=9ab0b78b8fbd60efa18a38634ccfda9101a4d27e commit 9ab0b78b8fbd60efa18a38634ccfda9101a4d27e Author: Guillem Jover <[email protected]> AuthorDate: Wed Jun 25 01:11:02 2025 +0200 Test::Dpkg: Refactor all_pod_modules() function Move this function from the pod-coverage.t unit test, so that we can further refactor its code, and then do not need to export the directory getter functions. --- scripts/Test/Dpkg.pm | 37 +++++++++++++++++++++++++++++++++++++ t/pod-coverage.t | 38 +------------------------------------- 2 files changed, 38 insertions(+), 37 deletions(-) diff --git a/scripts/Test/Dpkg.pm b/scripts/Test/Dpkg.pm index d8a2255f7..b07c402ad 100644 --- a/scripts/Test/Dpkg.pm +++ b/scripts/Test/Dpkg.pm @@ -37,6 +37,7 @@ our @EXPORT_OK = qw( all_shell_files all_perl_files all_perl_modules + all_pod_modules test_get_po_dirs test_get_perl_dirs test_get_data_path @@ -61,6 +62,7 @@ our %EXPORT_TAGS = ( all_shell_files all_perl_files all_perl_modules + all_pod_modules test_get_po_dirs test_get_perl_dirs test_get_data_path @@ -69,6 +71,7 @@ our %EXPORT_TAGS = ( ); use Exporter qw(import); +use List::Util qw(any); use Cwd; use File::Find; use File::Basename; @@ -182,6 +185,40 @@ sub all_perl_modules return _test_get_files(qr/\.pm$/, [ test_get_perl_dirs() ]); } +sub all_pod_modules +{ + my @modules_todo = @_; + my @modules; + + require Module::Metadata; + my $scan_perl_modules = sub { + my $module = $File::Find::name; + + # Only check modules, scripts are documented in man pages. + return unless $module =~ s/\.pm$//; + + my $mod = Module::Metadata->new_from_file($File::Find::name); + + # As a first step just check public modules (version > 0.xx). + return if $mod->version() =~ m/^0\.\d\d$/; + + $module =~ s{^\Q$File::Find::topdir\E/}{}; + $module =~ s{/}{::}g; + + return if any { $module eq $_ } @modules_todo; + + push @modules, $module; + }; + + my %options = ( + wanted => $scan_perl_modules, + no_chdir => 1, + ); + find(\%options, test_get_perl_dirs()); + + return @modules; +} + sub test_needs_author { if (not $ENV{AUTHOR_TESTING}) { diff --git a/t/pod-coverage.t b/t/pod-coverage.t index ebda98423..2452d31f9 100644 --- a/t/pod-coverage.t +++ b/t/pod-coverage.t @@ -15,49 +15,13 @@ use v5.36; -use List::Util qw(any); -use File::Find; -use Module::Metadata; - use Test::More; -use Test::Dpkg qw(:needs); +use Test::Dpkg qw(:needs :paths); test_needs_author(); test_needs_module('Test::Pod::Coverage'); test_needs_srcdir_switch(); -sub all_pod_modules -{ - my @modules_todo = @_; - my @modules; - my $scan_perl_modules = sub { - my $module = $File::Find::name; - - # Only check modules, scripts are documented in man pages. - return unless $module =~ s/\.pm$//; - - my $mod = Module::Metadata->new_from_file($File::Find::name); - - # As a first step just check public modules (version > 0.xx). - return if $mod->version() =~ m/^0\.\d\d$/; - - $module =~ s{^\Q$File::Find::topdir\E/}{}; - $module =~ s{/}{::}g; - - return if any { $module eq $_ } @modules_todo; - - push @modules, $module; - }; - - my %options = ( - wanted => $scan_perl_modules, - no_chdir => 1, - ); - find(\%options, Test::Dpkg::test_get_perl_dirs()); - - return @modules; -} - my @modules_todo = qw(Dpkg::Arch Dpkg::Source::Package); my @modules = all_pod_modules(@modules_todo); -- Dpkg.Org's dpkg

