Переглянути джерело

test: Add new common Test::Dpkg module

This will centralize common testsuite functions.
Guillem Jover 11 роки тому
батько
коміт
f38b214a69
4 змінених файлів з 45 додано та 7 видалено
  1. 0 1
      README
  2. 4 0
      scripts/Makefile.am
  3. 39 0
      scripts/Test/Dpkg.pm
  4. 2 6
      t/critic.t

+ 0 - 1
README

@@ -80,7 +80,6 @@ To run the test suite («make check»):
   IO-String perl module
   Test::Pod perl module (optional)
   Test::Perl::Critic perl module (optional)
-  Perl::Critic::Utils perl module (optional)
 
   Define the environment variable DPKG_DEVEL_MODE to run the test suite
   in development mode, to include tests that might not be pertinent during

+ 4 - 0
scripts/Makefile.am

@@ -116,6 +116,10 @@ nobase_dist_perllib_DATA = \
 	Dpkg/Version.pm \
 	Dpkg.pm
 
+EXTRA_DIST += \
+	Test/Dpkg.pm \
+	$(nil)
+
 # Keep it even if empty to have man3dir correctly set
 man3_MANS =
 

+ 39 - 0
scripts/Test/Dpkg.pm

@@ -0,0 +1,39 @@
+# Copyright © 2015 Guillem Jover <guillem@debian.org>
+#
+# This program 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 program 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 program.  If not, see <https://www.gnu.org/licenses/>.
+
+package Test::Dpkg;
+
+use strict;
+use warnings;
+
+our $VERSION = '0.00';
+our @EXPORT_OK = qw(all_perl_files);
+
+use Exporter qw(import);
+use File::Find;
+
+sub all_perl_files
+{
+    my @files;
+    my $scan_perl_files = sub {
+        push @files, $File::Find::name if m/\.(pl|pm|t)$/;
+    };
+
+    find($scan_perl_files, qw(t src/t lib utils/t scripts dselect));
+
+    return @files;
+}
+
+1;

+ 2 - 6
t/critic.t

@@ -17,6 +17,7 @@ use strict;
 use warnings;
 
 use Test::More;
+use Test::Dpkg;
 
 unless (defined $ENV{DPKG_DEVEL_MODE}) {
     plan skip_all => 'not running in development mode';
@@ -29,9 +30,6 @@ if (defined $ENV{srcdir}) {
 if (not eval { require Test::Perl::Critic }) {
     plan skip_all => 'Test::Perl::Critic required to criticize code';
 }
-if (not eval { require Perl::Critic::Utils }) {
-    plan skik_all => 'Perl::Critic::Utils required to criticize code';
-}
 
 my @policies = qw(
     BuiltinFunctions::ProhibitBooleanGrep
@@ -128,9 +126,7 @@ Test::Perl::Critic->import(
     -only => 1,
 );
 
-my @dirs = qw(t src/t utils/t scripts/t dselect scripts/Dpkg);
-my @files = glob 'scripts/Dpkg.pm scripts/*.pl scripts/changelog/*.pl';
-push @files, Perl::Critic::Utils::all_perl_files(@dirs);
+my @files = Test::Dpkg::all_perl_files();
 
 plan tests => scalar @files;