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=d37957d7d9d471eb2509085c570130ebda46228b commit d37957d7d9d471eb2509085c570130ebda46228b Author: Guillem Jover <[email protected]> AuthorDate: Wed Jun 25 01:31:23 2025 +0200 Test::Dpkg: Refactor test files scan function Make it not change directory, so that we get the full pathname, and make it always take a keep function, so that we can filter based on filenames or file contents. --- scripts/Test/Dpkg.pm | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/scripts/Test/Dpkg.pm b/scripts/Test/Dpkg.pm index 00dbd7665..a15b37642 100644 --- a/scripts/Test/Dpkg.pm +++ b/scripts/Test/Dpkg.pm @@ -132,22 +132,33 @@ sub _test_get_perl_dirs } } -sub _test_get_files +sub _test_scan_files($visit_func, $dirs) +{ + find({ + wanted => $visit_func, + no_chdir => 1, + }, @{$dirs}); +} + +sub _test_get_files($keep_func, $dirs) { - my ($filter, $dirs) = @_; my @files; - my $scan_files = sub { - push @files, $File::Find::name if m/$filter/; + my $visit_func = sub { + push @files, $File::Find::name if $keep_func->($File::Find::name); }; - find($scan_files, @{$dirs}); + _test_scan_files($visit_func, $dirs); return @files; } sub all_po_files { - return _test_get_files(qr/\.(?:po|pot)$/, [ _test_get_po_dirs() ]); + my $keep_po_files = sub ($file) { + return $file =~ m{\.(?:po|pot)$}; + }; + + return _test_get_files($keep_po_files, [ _test_get_po_dirs() ]); } sub all_shell_files @@ -172,12 +183,20 @@ sub all_shell_files sub all_perl_files { - return _test_get_files(qr/\.(?:PL|pl|pm|t)$/, [ _test_get_perl_dirs() ]); + my $keep_perl_files = sub ($file) { + return $file =~ m{\.(?:PL|pl|pm|t)$}; + }; + + return _test_get_files($keep_perl_files, [ _test_get_perl_dirs() ]); } sub all_perl_modules { - return _test_get_files(qr/\.pm$/, [ _test_get_perl_dirs() ]); + my $keep_perl_modules = sub ($file) { + return $file =~ m{\.pm$}; + }; + + return _test_get_files($keep_perl_modules, [ _test_get_perl_dirs() ]); } sub all_pod_modules @@ -206,11 +225,7 @@ sub all_pod_modules push @modules, $module; }; - my %options = ( - wanted => $scan_perl_modules, - no_chdir => 1, - ); - find(\%options, _test_get_perl_dirs()); + _test_scan_files($scan_perl_modules, [ _test_get_perl_dirs() ]); return @modules; } -- Dpkg.Org's dpkg

