[SCM] Debian package checker branch, vendor-profile, updated. 2.5.1-22-gfde21b9
The following commit has been merged in the vendor-profile branch:
commit fde21b9bac16b3a5c7835546c8bd1cc47f911f7b
Author: Niels Thykier <niels@thykier.net>
Date: Tue Jun 21 19:47:30 2011 +0200
Added check for profiles covering all tags
diff --git a/t/scripts/profiles-coverage.t b/t/scripts/profiles-coverage.t
new file mode 100755
index 0000000..0da9b15
--- /dev/null
+++ b/t/scripts/profiles-coverage.t
@@ -0,0 +1,85 @@
+#!/usr/bin/perl
+
+# Test for complete coverage of tags in profiles
+# - side-effect, test that all tags and checks
+# in the profiles are valid.
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use Lintian::Tag::Info;
+use File::Find;
+require Util; # Test::More (also) exports fail
+
+my $root = $ENV{'LINTIAN_ROOT'};
+my @profiles;
+my %CHECKS;
+my %TAGS;
+
+foreach my $desc (<$root/checks/*.desc>) {
+ my ($header, @tags) = Util::read_dpkg_control($desc);
+ my $list = [];
+ unless ($header->{'check-script'}) {
+ fail("missing Check-Script field in $desc");
+ }
+ $CHECKS{$header->{'check-script'}} = $list;
+ for my $tag (@tags) {
+ unless ($tag->{tag}) {
+ fail("missing Tag field in $desc");
+ }
+ push @$list, $tag->{tag};
+ $TAGS{$tag->{tag}} = 0;
+ }
+}
+
+plan tests => scalar (keys %TAGS);
+
+File::Find::find(\&prof_wanted, "$root/profiles");
+
+foreach my $tag (sort keys %TAGS){
+ cmp_ok($TAGS{$tag}, '>', 0, $tag);
+}
+
+exit 0;
+
+## SUBS ##
+
+sub parse_profile {
+ my ($profile) = @_;
+ my ($header, @section) = Util::read_dpkg_control($profile);
+ my $en_checks = $header->{'enable-tags-from-check'}//'';
+ my $dis_checks = $header->{'disable-tags-from-check'}//'';
+ my $en_tag = $header->{'enable-tag'}//'';
+ my $dis_tag = $header->{'disable-tag'}//'';
+ foreach my $check (split m/\s*+,\s*+/o, $en_checks){
+ die "Unknown check in $profile.\n" unless $CHECKS{$check};
+ foreach my $tag (@{$CHECKS{$check}}){
+ $TAGS{$tag}++;
+ }
+ }
+ foreach my $tag (split m/\s*+,\s*+/o, $en_tag){
+ die "Unknown tag in $profile.\n" unless exists $TAGS{$tag};
+ $TAGS{$tag}++;
+ }
+
+ # Check for unknown checks in the other fields
+ foreach my $check (split m/\s*+,\s*+/o, $dis_checks){
+ die "Unknown check in $profile.\n" unless $CHECKS{$check};
+ }
+ foreach my $tag (split m/\s*+,\s*+/o, $dis_tag){
+ die "Unknown tag in $profile.\n" unless exists $TAGS{$tag};
+ }
+ # ... and other fields
+ foreach my $sect (@section){
+ foreach my $tag (split m/\s*+,\s*+/o, $sect->{'tag'}){
+ die "Unknown tag in $profile.\n" unless exists $TAGS{$tag};
+ }
+ }
+}
+
+sub prof_wanted {
+ parse_profile($_) if -f && m/\.profile$/o;
+}
+
--
Debian package checker
Reply to: