[dpkg] 43/192: test: Add new module-version unit test
Ximin Luo
infinity0 at debian.org
Tue Oct 17 11:03:56 UTC 2017
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch pu/reproducible_builds
in repository dpkg.
commit 9e8530f5e7d89c8abe9e6cf782a11698f280127c
Author: Guillem Jover <guillem at debian.org>
Date: Thu May 18 00:16:49 2017 +0200
test: Add new module-version unit test
This will check that the module $VERSION matches the newest entry
in the CHANGES section if there is any POD present.
---
Makefile.am | 1 +
debian/changelog | 2 ++
t/module-version.t | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 76 insertions(+)
diff --git a/Makefile.am b/Makefile.am
index 0da52cb..4e04459 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -153,6 +153,7 @@ test_scripts = \
t/pod-coverage.t \
t/synopsis.t \
t/minimum-version.t \
+ t/module-version.t \
t/syntax.t \
t/strict.t \
t/critic.t \
diff --git a/debian/changelog b/debian/changelog
index 5dc0bde..a8acb78 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -14,6 +14,8 @@ dpkg (1.19.0) UNRELEASED; urgency=medium
Miscellanea::ProhibitTies.
- Disable perlcritic ValuesAndExpressions::ProhibitEscapedCharacter.
- Add a new all_perl_modules function to Test::Dpkg.
+ - Add a new module-version unit test to check that module $VERSION
+ matches the newest entry in the CHANGES section.
-- Guillem Jover <guillem at debian.org> Thu, 18 May 2017 05:27:31 +0200
diff --git a/t/module-version.t b/t/module-version.t
new file mode 100644
index 0000000..401f373
--- /dev/null
+++ b/t/module-version.t
@@ -0,0 +1,73 @@
+#!/usr/bin/perl
+#
+# 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/>.
+
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Dpkg qw(:needs);
+use Module::Metadata;
+
+test_needs_srcdir_switch();
+
+my @files = Test::Dpkg::all_perl_modules();
+
+plan tests => scalar @files;
+
+sub module_version_ok
+{
+ my $file = shift;
+
+ my $mod = Module::Metadata->new_from_file($file, collect_pod => 1);
+ my $modver = $mod->version();
+ my $podver;
+
+ SKIP: {
+ if ($mod->contains_pod()) {
+ my $in_changes = 0;
+
+ foreach my $sect ($mod->pod_inside) {
+ if ($sect eq 'CHANGES') {
+ $in_changes = 1;
+ next;
+ }
+
+ if ($in_changes and $sect =~ m/^Version ([0-9x.]+)/) {
+ $podver = $1;
+ last;
+ }
+ }
+
+ if (not $in_changes) {
+ fail("module $file does not contain a CHANGES POD section");
+ return;
+ }
+ } else {
+ skip("module $file does not contain POD", 1);
+ }
+
+ if (defined $podver and $podver eq '0.xx') {
+ ok($modver =~ m/^0.\d\d$/,
+ "module $file version $modver is POD version 0.xx");
+ } else {
+ ok($modver eq $podver,
+ "module $file version $modver == POD version $podver");
+ }
+ }
+}
+
+foreach my $file (@files) {
+ module_version_ok($file);
+};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git
More information about the Reproducible-commits
mailing list