[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[SCM] Debian package checker branch, master, updated. 2.2.9-50-g3b6ceb0



The following commit has been merged in the master branch:
commit 3b6ceb0c6978eaabb09067465f49e5c4096aa973
Author: Russ Allbery <rra@debian.org>
Date:   Mon Apr 27 15:03:11 2009 -0700

    Rewrite needs-info in Perl
    
    No need to reinvent Test::More in shell or use sed instead of our
    existing utility functions to parse dpkg control files.  The Perl
    version is shorter and easier to read.

diff --git a/t/scripts/needs-info.t b/t/scripts/needs-info.t
old mode 100644
new mode 100755
index 30a203c..104193f
--- a/t/scripts/needs-info.t
+++ b/t/scripts/needs-info.t
@@ -1,59 +1,44 @@
 #!/usr/bin/perl
 
-true and exec '/bin/sh', $0;
-__END__ 2>/dev/null || true
-
-# Test to make sure all the collection scripts listed in the Needs-Info fields
-# of {checks,collection}/*desc do exist
-
-# Perl's prove, the shell way :)
-
-####################
-#    Copyright (C) 2009 by Raphael Geissert <atomo64@gmail.com>
+# Copyright (C) 2009 by Raphael Geissert <atomo64@gmail.com>
+# Copyright (C) 2009 Russ Allbery <rra@debian.org>
 #
+# This file is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
 #
-#    This file is free software: you can redistribute it and/or modify
-#    it under the terms of the GNU General Public License as published by
-#    the Free Software Foundation, either version 2 of the License, or
-#    (at your option) any later version.
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
 #
-#    This file is distributed in the hope that it will be useful,
-#    but WITHOUT ANY WARRANTY; without even the implied warranty of
-#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#    GNU General Public License for more details.
-#
-#    You should have received a copy of the GNU General Public License
-#    along with this file.  If not, see <http://www.gnu.org/licenses/>.
-####################
-
-set -e
-
-LINTIAN_ROOT=${LINTIAN_ROOT:=$(pwd)}
-
-descs="$(find "$LINTIAN_ROOT/collection/" "$LINTIAN_ROOT/checks/" \
-	-name '*desc' -type f)"
-
-total="$(echo "$descs" | wc -l)"
-
-printf "1..%d\n" "$total"
-
-c=1
-
-echo "$descs" |
-while read desc; do
-    needs="$(sed -n 's/^Needs-Info:\s*//g;T;s/,/ /g;s/\s+/ /g;p' "$desc")"
-    missing=
-    for coll in $needs; do
-	[ -f "$LINTIAN_ROOT/collection/$coll" ] || {
-	    missing="$missing
-#   Missing collection script '$coll' detected
-#   at $desc"
-	}
-    done
-    [ -z "$missing" ] || printf 'not '
-    printf 'ok %d - %s has valid needs-info\n' "$c" "${desc#$LINTIAN_ROOT/}"
-    [ -z "$missing" ] || printf '%s\n' "$missing" >&2
-    c=$((c+1))
-done
-
-exit
+# You should have received a copy of the GNU General Public License
+# along with this file.  If not, see <http://www.gnu.org/licenses/>.
+
+use strict;
+
+use Test::More;
+use Util qw(read_dpkg_control);
+
+# Find all of the desc files in either collection or checks.  We'll do one
+# check per description.
+our @DESCS = (<$ENV{LINTIAN_ROOT}/collection/*.desc>,
+              <$ENV{LINTIAN_ROOT}/checks/*.desc>);
+plan tests => scalar(@DESCS);
+
+# For each desc file, load the first stanza of the file and check that all of
+# its Needs-Info script references exist.
+for my $desc (@DESCS) {
+    my ($header) = read_dpkg_control($desc);
+    my @needs = split(/\s*,\s*/, $header->{'needs-info'} || '');
+    my @missing;
+    for my $coll (@needs) {
+        unless (-f "$ENV{LINTIAN_ROOT}/collection/$coll") {
+            push(@missing, $coll);
+        }
+    }
+    my $short = $desc;
+    $short =~ s/^\Q$ENV{LINTIAN_ROOT}//;
+    is(join(', ', @missing), '', "$short has valid needs-info");
+}

-- 
Debian package checker


Reply to: