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

[lintian] 01/02: T::Lintian: Drop translation specific code



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

nthykier pushed a commit to branch master
in repository lintian.

commit 6059bc8c78104908116788f132dfe9141cd67a59
Author: Niels Thykier <niels@thykier.net>
Date:   Fri Aug 5 16:01:04 2016 +0000

    T::Lintian: Drop translation specific code
    
    Signed-off-by: Niels Thykier <niels@thykier.net>
---
 lib/Test/Lintian.pm | 154 +++++++++++++++++-----------------------------------
 1 file changed, 49 insertions(+), 105 deletions(-)

diff --git a/lib/Test/Lintian.pm b/lib/Test/Lintian.pm
index 8e192db..14b05a6 100644
--- a/lib/Test/Lintian.pm
+++ b/lib/Test/Lintian.pm
@@ -157,17 +157,12 @@ sub test_check_desc {
     my $colldir = '/usr/share/lintian/collection';
     my $find_opt = {'filter' => undef,};
     my $tested = 0;
-    my $is_translation = 0;
-    my $content_type_base = 'Check';
 
     if (ref $_[0] eq 'HASH') {
         $opts = shift;
         $colldir = $opts->{'coll-dir'}//'' if exists $opts->{'coll-dir'};
         $find_opt->{'filter'} = $opts->{'filter'} if exists $opts->{'filter'};
-        $is_translation = $opts->{'translation'}
-          if exists $opts->{'translation'};
     }
-    $content_type_base = 'Check-Translation' if $is_translation;
     $opts //= {};
     @descs = @_;
     load_profile_for_test();
@@ -181,45 +176,23 @@ sub test_check_desc {
             $builder->diag("Error: $err");
             next;
         }
-        my $content_type = $content_type_base;
+        my $content_type = 'Check';
         my $cname = $header->{'check-script'}//'';
         my $ctype = $header->{'type'} // '';
         my $needs = $header->{'needs-info'} // '';
-        my $tname = $header->{'check-script-translation'} // '';
         my $i = 1; # paragraph counter.
         $builder->ok(1, "Can parse check $desc_file");
 
-        if ($is_translation) {
-            $builder->isnt_eq($tname, '',
-                "$content_type has a name ($desc_file)");
-            $builder->is_eq($cname, '',
-                    "$content_type does not have the "
-                  . " Check-Script field ($desc_file)");
-            # Use $cname from here on as the name of the check.
-            $cname = $tname;
-            if ($tname ne '') {
-                # If the check has a name, we can also what language
-                # it is for (based on the file name).
-                my $lang = basename($desc_file, '.desc');
-                $lang =~ s/\Q$tname\E_//;
-                $content_type .= "[$lang]";
-            }
-        } else {
-            $builder->isnt_eq($cname, '',
-                "$content_type has a name ($desc_file)");
-            $builder->is_eq($tname, '',
-                    "$content_type does not have the "
-                  . " Check-Script-Translation field ($desc_file)");
-        }
+        $builder->isnt_eq($cname, '',
+            "$content_type has a name ($desc_file)");
+
         # From here on, we just use "$cname" as name of the check, so
         # we don't need to choose been it and $tname.
         $cname = '<missing>' if $cname eq '';
         $tested += 2;
 
-        if ($is_translation or $cname eq 'lintian') {
-            my $reason = 'translations have no type';
-            $reason = 'check "lintian" does not have a type'
-              if not $is_translation;
+        if ($cname eq 'lintian') {
+            my $reason = 'check "lintian" does not have a type';
             # skip these two tests for this special case...
             $builder->skip("Special case, $reason");
             $builder->skip("Special case, $reason");
@@ -238,20 +211,14 @@ sub test_check_desc {
         }
 
         if ($needs and $colldir ne '') {
-
+            my @bad;
             # new lines are not allowed, map them to "\\n" for readability.
             $needs =~ s/\n/\\n/go;
-            if ($is_translation) {
-                $builder->is_eq('', $needs,
-                    "Translations for $cname ". 'should not have Needs-Info');
-            } else {
-                my @bad;
-                foreach my $need (split m/\s*+,\s*+/o, $needs) {
-                    push @bad, $need unless -f "$colldir/$need.desc";
-                }
-                $builder->is_eq(join(', ', @bad),
-                    '', "$cname has unknown collections in Needs-Info");
+            foreach my $need (split m/\s*+,\s*+/o, $needs) {
+                push @bad, $need unless -f "$colldir/$need.desc";
             }
+            $builder->is_eq(join(', ', @bad),
+                '', "$cname has unknown collections in Needs-Info");
         } else {
             $builder->ok(1, "$content_type has a valid Needs-Info (empty)")
               if $colldir ne '';
@@ -260,17 +227,13 @@ sub test_check_desc {
               if $needs ne '';
         }
 
-        if ($is_translation) {
-            $builder->skip('Skip language specific test');
-        } else {
-            my $mistakes = 0;
-            my $handler = sub {
-                my ($incorrect, $correct) = @_;
-                $builder->diag("Spelling ($cname): $incorrect => $correct");
-                $mistakes++;
-            };
-            $builder->is_eq($mistakes, 0,"$cname Info has no spelling errors");
-        }
+        my $mistakes = 0;
+        my $handler = sub {
+            my ($incorrect, $correct) = @_;
+            $builder->diag("Spelling ($cname): $incorrect => $correct");
+            $mistakes++;
+        };
+        $builder->is_eq($mistakes, 0,"$cname Info has no spelling errors");
 
         foreach my $tpara (@tagpara) {
             my $tag = $tpara->{'tag'}//'';
@@ -291,52 +254,37 @@ sub test_check_desc {
               or $builder->diag("$cname: $tag\n");
 
             # Severity / Certainty
-            if ($is_translation) {
-                $builder->is_eq($severity, '',
-                    "$content_type $cname:". " $tag should not have severity");
-                $builder->is_eq($certainty, '',
-                        "$content_type $cname:"
-                      . " $tag should not have certainty");
-            } else {
-                $builder->ok($severity && exists $severities{$severity},
-                    'Tag has valid severity')
-                  or $builder->diag("$cname: $tag severity: $severity\n");
-                $builder->ok($certainty && exists $certainties{$certainty},
-                    'Tag has valid certainty')
-                  or $builder->diag("$cname: $tag certainty: $certainty\n");
-            }
+            $builder->ok($severity && exists $severities{$severity},
+                'Tag has valid severity')
+              or $builder->diag("$cname: $tag severity: $severity\n");
+            $builder->ok($certainty && exists $certainties{$certainty},
+                'Tag has valid certainty')
+              or $builder->diag("$cname: $tag certainty: $certainty\n");
 
             # Info
-            if ($is_translation) {
-                $builder->skip('Skip language specific test');
-                $builder->skip('Skip language specific test');
-                $builder->skip('Skip language specific test');
-                $builder->skip('Skip language specific test');
-            } else {
-                my $mistakes = 0;
-                my $handler = sub {
-                    my ($incorrect, $correct) = @_;
-                    $builder->diag(
-                        "Spelling ($cname/$tag): $incorrect => $correct");
-                    $mistakes++;
-                };
-                $builder->is_eq($mistakes, 0,
-                    "$content_type $cname: $tag has no spelling errors");
-
-                $builder->ok($info !~ /(?:^| )(?:[Ww]e|I)\b/,
-                    'Tag info does not speak of "I", or "we"')
-                  or $builder->diag("$content_type $cname: $tag\n");
-
-                $builder->ok(
-                    $info !~ /(\S\w)\. [^ ]/
-                      || $1 =~ '/^\.[ge]$/', # for 'e.g.'/'i.e.'
-                    'Tag info uses two spaces after a full stop'
-                ) or $builder->diag("$content_type $cname: $tag\n");
-
-                $builder->ok($info !~ /(\S\w\.   )/,
-                    'Tag info uses only two spaces after a full stop')
-                  or $builder->diag("$content_type $cname: $tag ($1)\n");
-            }
+            my $mistakes = 0;
+            my $handler = sub {
+                my ($incorrect, $correct) = @_;
+                $builder->diag(
+                    "Spelling ($cname/$tag): $incorrect => $correct");
+                $mistakes++;
+            };
+            $builder->is_eq($mistakes, 0,
+                "$content_type $cname: $tag has no spelling errors");
+
+            $builder->ok($info !~ /(?:^| )(?:[Ww]e|I)\b/,
+                'Tag info does not speak of "I", or "we"')
+              or $builder->diag("$content_type $cname: $tag\n");
+
+            $builder->ok(
+                $info !~ /(\S\w)\. [^ ]/
+                  || $1 =~ '/^\.[ge]$/', # for 'e.g.'/'i.e.'
+                'Tag info uses two spaces after a full stop'
+            ) or $builder->diag("$content_type $cname: $tag\n");
+
+            $builder->ok($info !~ /(\S\w\.   )/,
+                'Tag info uses only two spaces after a full stop')
+              or $builder->diag("$content_type $cname: $tag ($1)\n");
 
             $builder->ok(
                 is_string_utf8_encoded($info),
@@ -367,12 +315,8 @@ sub test_check_desc {
         }
     }
 
-    if ($is_translation) {
-        $builder->skip('Translations are not required');
-    } else {
-        $builder->cmp_ok($tested, '>', 0, 'Tested at least one desc file')
-          if @descs;
-    }
+    $builder->cmp_ok($tested, '>', 0, 'Tested at least one desc file')
+      if @descs;
     return;
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/lintian/lintian.git


Reply to: