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=6b5fcfd0f8ed354de31ffdbd9f96d60f85ea77ef

commit 6b5fcfd0f8ed354de31ffdbd9f96d60f85ea77ef (HEAD -> main)
Author: Guillem Jover <[email protected]>
AuthorDate: Tue Sep 23 04:19:54 2025 +0200

    Test::Dpkg: Rename test_needs_srcdir_switch() to test_chdir_srcdir()
    
    This was not really a function declaring that we need a specific
    feature, it was requesting to change the running context to fit the
    test expectations.
---
 scripts/Test/Dpkg.pm    | 18 +++++++++---------
 scripts/t/Dpkg_Shlibs.t |  2 +-
 t/codespell.t           |  5 +++--
 t/cppcheck.t            |  5 +++--
 t/critic.t              |  5 +++--
 t/minimum-version.t     |  5 +++--
 t/module-version.t      |  4 ++--
 t/po.t                  |  5 +++--
 t/pod-coverage.t        |  3 ++-
 t/pod-spell.t           |  4 ++--
 t/pod.t                 |  3 ++-
 t/shellcheck.t          |  3 ++-
 t/strict.t              |  5 +++--
 t/synopsis.t            |  5 +++--
 t/syntax.t              |  4 ++--
 15 files changed, 43 insertions(+), 33 deletions(-)

diff --git a/scripts/Test/Dpkg.pm b/scripts/Test/Dpkg.pm
index 818b13ff9..ce1386d98 100644
--- a/scripts/Test/Dpkg.pm
+++ b/scripts/Test/Dpkg.pm
@@ -40,11 +40,11 @@ our @EXPORT_OK = qw(
     all_pod_modules
     test_get_data_path
     test_get_temp_path
+    test_chdir_srcdir
     test_needs_author
     test_needs_module
     test_needs_command
     test_needs_openpgp_backend
-    test_needs_srcdir_switch
     test_neutralize_checksums
 );
 our %EXPORT_TAGS = (
@@ -53,7 +53,6 @@ our %EXPORT_TAGS = (
         test_needs_module
         test_needs_command
         test_needs_openpgp_backend
-        test_needs_srcdir_switch
     ) ],
     paths => [ qw(
         all_po_files
@@ -63,6 +62,7 @@ our %EXPORT_TAGS = (
         all_pod_modules
         test_get_data_path
         test_get_temp_path
+        test_chdir_srcdir
     ) ],
 );
 
@@ -114,6 +114,13 @@ sub test_get_temp_path
     return $path;
 }
 
+sub test_chdir_srcdir
+{
+    if (defined $ENV{srcdir}) {
+        chdir $ENV{srcdir} or BAIL_OUT("cannot chdir to source directory: $!");
+    }
+}
+
 sub _test_get_po_dirs
 {
     if ($test_mode eq 'cpan') {
@@ -390,13 +397,6 @@ sub test_needs_openpgp_backend
     return @have_backends;
 }
 
-sub test_needs_srcdir_switch
-{
-    if (defined $ENV{srcdir}) {
-        chdir $ENV{srcdir} or BAIL_OUT("cannot chdir to source directory: $!");
-    }
-}
-
 sub test_neutralize_checksums
 {
     my $filename = shift;
diff --git a/scripts/t/Dpkg_Shlibs.t b/scripts/t/Dpkg_Shlibs.t
index 1853cf420..b321cc0f7 100644
--- a/scripts/t/Dpkg_Shlibs.t
+++ b/scripts/t/Dpkg_Shlibs.t
@@ -75,7 +75,7 @@ Dpkg::Shlibs::blank_library_paths();
 # is usually a relative path, so let us temporarily switch directory.
 # XXX: An alternative would be to make parse_ldso_conf relative path aware.
 my $cwd = getcwd();
-test_needs_srcdir_switch();
+test_chdir_srcdir();
 Dpkg::Shlibs::parse_ldso_conf('t/Dpkg_Shlibs/ld.so.conf');
 chdir($cwd);
 
diff --git a/t/codespell.t b/t/codespell.t
index 33a22ee49..01cefdb8b 100644
--- a/t/codespell.t
+++ b/t/codespell.t
@@ -16,13 +16,14 @@
 use v5.36;
 
 use Test::More;
-use Test::Dpkg qw(:needs);
+use Test::Dpkg qw(:needs :paths);
 
 test_needs_author();
 test_needs_command('codespell');
-test_needs_srcdir_switch();
 plan tests => 1;
 
+test_chdir_srcdir();
+
 my @codespell_skip = qw(
     .git
     *.po
diff --git a/t/cppcheck.t b/t/cppcheck.t
index f2640f485..f32e9b7f2 100644
--- a/t/cppcheck.t
+++ b/t/cppcheck.t
@@ -16,14 +16,15 @@
 use v5.36;
 
 use Test::More;
-use Test::Dpkg qw(:needs);
+use Test::Dpkg qw(:needs :paths);
 
 test_needs_author();
 test_needs_command('cppcheck');
-test_needs_srcdir_switch();
 plan skip_all => 'expensive test in short mode' if $ENV{SHORT_TESTING};
 plan tests => 1;
 
+test_chdir_srcdir();
+
 my $builddir = $ENV{abs_top_builddir} || '.';
 
 my @cppcheck_opts = (qw(
diff --git a/t/critic.t b/t/critic.t
index d0cb21157..53a8b9451 100644
--- a/t/critic.t
+++ b/t/critic.t
@@ -16,11 +16,12 @@
 use v5.36;
 
 use Test::More;
-use Test::Dpkg qw(:needs);
+use Test::Dpkg qw(:needs :paths);
 
 test_needs_author();
 test_needs_module('Test::Perl::Critic');
-test_needs_srcdir_switch();
+
+test_chdir_srcdir();
 
 my @policies = qw(
     BuiltinFunctions::ProhibitBooleanGrep
diff --git a/t/minimum-version.t b/t/minimum-version.t
index d5f6336d1..582111656 100644
--- a/t/minimum-version.t
+++ b/t/minimum-version.t
@@ -16,11 +16,12 @@
 use v5.36;
 
 use Test::More;
-use Test::Dpkg qw(:needs);
+use Test::Dpkg qw(:needs :paths);
 
 test_needs_author();
 test_needs_module('Test::MinimumVersion');
-test_needs_srcdir_switch();
+
+test_chdir_srcdir();
 
 my @files = Test::Dpkg::all_perl_files();
 
diff --git a/t/module-version.t b/t/module-version.t
index 7d6fb8790..1a3e5719d 100644
--- a/t/module-version.t
+++ b/t/module-version.t
@@ -16,10 +16,10 @@
 use v5.36;
 
 use Test::More;
-use Test::Dpkg qw(:needs);
+use Test::Dpkg qw(:needs :paths);
 use Module::Metadata;
 
-test_needs_srcdir_switch();
+test_chdir_srcdir();
 
 my @files = Test::Dpkg::all_perl_modules();
 
diff --git a/t/po.t b/t/po.t
index cba1e6dfe..bb4809566 100644
--- a/t/po.t
+++ b/t/po.t
@@ -16,11 +16,12 @@
 use v5.36;
 
 use Test::More;
-use Test::Dpkg qw(:needs);
+use Test::Dpkg qw(:needs :paths);
 
 test_needs_author();
 test_needs_command('i18nspector');
-test_needs_srcdir_switch();
+
+test_chdir_srcdir();
 
 my @files = Test::Dpkg::all_po_files();
 
diff --git a/t/pod-coverage.t b/t/pod-coverage.t
index 2452d31f9..79c5801b9 100644
--- a/t/pod-coverage.t
+++ b/t/pod-coverage.t
@@ -20,7 +20,8 @@ use Test::Dpkg qw(:needs :paths);
 
 test_needs_author();
 test_needs_module('Test::Pod::Coverage');
-test_needs_srcdir_switch();
+
+test_chdir_srcdir();
 
 my @modules_todo = qw(Dpkg::Arch Dpkg::Source::Package);
 my @modules = all_pod_modules(@modules_todo);
diff --git a/t/pod-spell.t b/t/pod-spell.t
index a1e177ae7..6468e40c3 100644
--- a/t/pod-spell.t
+++ b/t/pod-spell.t
@@ -16,7 +16,7 @@
 use v5.36;
 
 use Test::More;
-use Test::Dpkg qw(:needs);
+use Test::Dpkg qw(:needs :paths);
 
 test_needs_author();
 test_needs_module('Test::Spelling');
@@ -26,7 +26,7 @@ if (qx(aspell dicts) !~ m/en_US/) {
     plan skip_all => 'aspell en_US dictionary required for spell checking POD';
 }
 
-test_needs_srcdir_switch();
+test_chdir_srcdir();
 
 my @files = Test::Dpkg::all_perl_files();
 
diff --git a/t/pod.t b/t/pod.t
index 8f2cddfda..18974d411 100644
--- a/t/pod.t
+++ b/t/pod.t
@@ -19,7 +19,8 @@ use Test::More;
 use Test::Dpkg qw(:needs :paths);
 
 test_needs_module('Test::Pod', '1.00');
-test_needs_srcdir_switch();
+
+test_chdir_srcdir();
 
 my @files = Test::Dpkg::all_perl_files();
 
diff --git a/t/shellcheck.t b/t/shellcheck.t
index c7329895a..03834a16d 100644
--- a/t/shellcheck.t
+++ b/t/shellcheck.t
@@ -20,7 +20,8 @@ use Test::Dpkg qw(:needs :paths);
 
 test_needs_author();
 test_needs_command('shellcheck');
-test_needs_srcdir_switch();
+
+test_chdir_srcdir();
 
 my @files_todo = qw(
     dselect/methods/file/install.sh
diff --git a/t/strict.t b/t/strict.t
index 2062f99d5..341936478 100644
--- a/t/strict.t
+++ b/t/strict.t
@@ -16,10 +16,11 @@
 use v5.36;
 
 use Test::More;
-use Test::Dpkg qw(:needs);
+use Test::Dpkg qw(:needs :paths);
 
 test_needs_module('Test::Strict');
-test_needs_srcdir_switch();
+
+test_chdir_srcdir();
 
 eval '$Test::Strict::TEST_WARNINGS = 1';
 # XXX: Remove once https://github.com/manwar/Test-Strict/pull/37 gets released.
diff --git a/t/synopsis.t b/t/synopsis.t
index 13286f744..3078edfff 100644
--- a/t/synopsis.t
+++ b/t/synopsis.t
@@ -16,11 +16,12 @@
 use v5.36;
 
 use Test::More;
-use Test::Dpkg qw(:needs);
+use Test::Dpkg qw(:needs :paths);
 
 test_needs_author();
 test_needs_module('Test::Synopsis');
-test_needs_srcdir_switch();
+
+test_chdir_srcdir();
 
 my @files = Test::Dpkg::all_perl_files();
 
diff --git a/t/syntax.t b/t/syntax.t
index 21d3e91ef..2ab7af433 100644
--- a/t/syntax.t
+++ b/t/syntax.t
@@ -16,9 +16,9 @@
 use v5.36;
 
 use Test::More;
-use Test::Dpkg qw(:needs);
+use Test::Dpkg qw(:paths);
 
-test_needs_srcdir_switch();
+test_chdir_srcdir();
 
 my @files = Test::Dpkg::all_perl_files();
 

-- 
Dpkg.Org's dpkg

Reply via email to