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

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=d9bc580a419232420abb9620638cfbfe74943ff2

commit d9bc580a419232420abb9620638cfbfe74943ff2
Author: Guillem Jover <[email protected]>
AuthorDate: Wed May 23 03:58:27 2018 +0200

    test: Add new po author test
    
    Use i18nspector (if available) to check the .po and .pot files.
---
 Makefile.am            |  1 +
 debian/changelog       |  1 +
 scripts/Test/Dpkg.pm   | 26 ++++++++++++++++++++++++++
 t/{synopsis.t => po.t} | 24 +++++++++++++++++++++---
 4 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 05bf93835..972889a89 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -149,6 +149,7 @@ coverage-clean:
 endif
 
 test_scripts = \
+       t/po.t \
        t/pod.t \
        t/pod-spell.t \
        t/pod-coverage.t \
diff --git a/debian/changelog b/debian/changelog
index 81490983b..2ceefc850 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -159,6 +159,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium
     - Consider *.PL also to be perl files.
     - Infer automatically the unit test data directory.
     - Infer automatically the unit test temp directory.
+    - Add new po author test case (use i18nspector if available).
 
   [ Updated programs translations ]
   * Dutch (Frans Spiesschaert). Closes: #881401
diff --git a/scripts/Test/Dpkg.pm b/scripts/Test/Dpkg.pm
index 4900e1f91..c59296858 100644
--- a/scripts/Test/Dpkg.pm
+++ b/scripts/Test/Dpkg.pm
@@ -20,8 +20,10 @@ use warnings;
 
 our $VERSION = '0.00';
 our @EXPORT_OK = qw(
+    all_po_files
     all_perl_files
     all_perl_modules
+    test_get_po_dirs
     test_get_perl_dirs
     test_get_data_path
     test_get_temp_path
@@ -39,8 +41,10 @@ our %EXPORT_TAGS = (
         test_needs_srcdir_switch
     ) ],
     paths => [ qw(
+        all_po_files
         all_perl_files
         all_perl_modules
+        test_get_po_dirs
         test_get_perl_dirs
         test_get_data_path
         test_get_temp_path
@@ -95,6 +99,15 @@ sub test_get_temp_path
     return $path;
 }
 
+sub test_get_po_dirs
+{
+    if ($test_mode eq 'cpan') {
+        return qw(po);
+    } else {
+        return qw(po scripts/po dselect/po man/po);
+    }
+}
+
 sub test_get_perl_dirs
 {
     if ($test_mode eq 'cpan') {
@@ -104,6 +117,19 @@ sub test_get_perl_dirs
     }
 }
 
+sub all_po_files
+{
+    my $filter = shift // qr/\.(?:po|pot)$/;
+    my @files;
+    my $scan_po_files = sub {
+        push @files, $File::Find::name if m/$filter/;
+    };
+
+    find($scan_po_files, test_get_po_dirs());
+
+    return @files;
+}
+
 sub all_perl_files
 {
     my $filter = shift // qr/\.(?:PL|pl|pm|t)$/;
diff --git a/t/synopsis.t b/t/po.t
similarity index 63%
copy from t/synopsis.t
copy to t/po.t
index 99835b602..d2c01bd3f 100644
--- a/t/synopsis.t
+++ b/t/po.t
@@ -20,13 +20,31 @@ use Test::More;
 use Test::Dpkg qw(:needs);
 
 test_needs_author();
-test_needs_module('Test::Synopsis');
+test_needs_command('i18nspector');
 test_needs_srcdir_switch();
 
-my @files = Test::Dpkg::all_perl_files();
+my @files = Test::Dpkg::all_po_files();
 
 plan tests => scalar @files;
 
+sub po_ok {
+    my $file = shift;
+
+    my $tags = qx(i18nspector \"$file\" 2>&1);
+
+    # Fixup the output:
+    $tags =~ s/^.*\.pot: boilerplate-in-initial-comments .*$//mg;
+    $tags =~ s/^.*\.po: duplicate-header-field X-POFile-SpellExtra$//mg;
+    chomp $tags;
+
+    my $ok = length $tags == 0;
+
+    ok($ok, "PO check $file");
+    if (not $ok) {
+        diag($tags);
+    }
+}
+
 for my $file (@files) {
-    synopsis_ok($file);
+    po_ok($file);
 }

-- 
Dpkg.Org's dpkg

Reply via email to