[pkg-perl-tools] 02/09: use.t: Refactor configuration file reading code

Niko Tyni ntyni at moszumanska.debian.org
Sat Dec 3 21:01:28 UTC 2016


This is an automated email from the git hooks/post-receive script.

ntyni pushed a commit to branch ntyni/autopkgtest
in repository pkg-perl-tools.

commit 8674f9f4a11eb59e254cbf55c918e2bde17526fd
Author: Niko Tyni <ntyni at debian.org>
Date:   Sun Nov 27 21:19:12 2016 +0200

    use.t: Refactor configuration file reading code
    
    We'll be using this for another purpose soon.
    
    Gbp-Dch: ignore
---
 autopkgtest/scripts/runtime-deps.d/use.t | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/autopkgtest/scripts/runtime-deps.d/use.t b/autopkgtest/scripts/runtime-deps.d/use.t
index db1e9e4..e34f3a5 100755
--- a/autopkgtest/scripts/runtime-deps.d/use.t
+++ b/autopkgtest/scripts/runtime-deps.d/use.t
@@ -24,20 +24,31 @@ sub getmodule {
     my $conffile = "debian/tests/pkg-perl/use-name";
     $conffile = "debian/tests/pkg-perl/module-name" if ! -e $conffile; # backcompat
     $conffile = "debian/tests/module-name" if ! -e $conffile; # backcompat squared
+
+    $module = read_conffile($conffile);
+    return $module if defined $module;
+    return getmeta();
+}
+
+sub read_conffile {
+    my $conffile = shift;
+    my $ret;
     if ( -f $conffile ) {
         open(M, "<", $conffile)
             or BAIL_OUT("$conffile exists but can't be read");
         while (<M>) {
             chomp;
             next if /^\s*#/;
-            /(\S+)/ and $module = $1, last;
+            /(\S+)/ and $ret = $1, last;
         }
         close M;
-        BAIL_OUT("can't find a module name in $conffile")
-            if !defined $module;
-        return $module;
+        BAIL_OUT("can't find anything in $conffile")
+            if !defined $ret;
     }
+    return $ret;
+}
 
+sub getmeta {
     my $meta;
     my $dist;
     eval { $meta = CPAN::Meta->load_file('META.json') };
@@ -47,7 +58,7 @@ sub getmodule {
 
     $dist = $meta->name;
 
-    $module = $dist;
+    my $module = $dist;
     $module =~ s,-,::,g;
 
     my $file = "$dist.pm";

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/pkg-perl-tools.git



More information about the Pkg-perl-cvs-commits mailing list